Examples of MyThreadFactory


Examples of com.packtpub.java7.concurrency.chapter1.recipe12.factory.MyThreadFactory

   * ten Thread objects using that Factory
   * @param args
   */
  public static void main(String[] args) {
    // Creates the factory
    MyThreadFactory factory=new MyThreadFactory("MyThreadFactory");
    // Creates a task
    Task task=new Task();
    Thread thread;
   
    // Creates and starts ten Thread objects
    System.out.printf("Starting the Threads\n");
    for (int i=0; i<10; i++){
      thread=factory.newThread(task);
      thread.start();
    }
    // Prints the statistics of the ThreadFactory to the console
    System.out.printf("Factory stats:\n");
    System.out.printf("%s\n",factory.getStats());
   
  }
View Full Code Here

Examples of com.packtpub.java7.concurrency.chapter7.recipe03.task.MyThreadFactory

   */
  public static void main(String[] args) throws Exception {
    /*
     * Create a Factory
     */
    MyThreadFactory myFactory=new MyThreadFactory("MyThreadFactory");
 
    /*
     * Crate a Task
     */
    MyTask task=new MyTask();
   
    /*
     * Create a Thread using the Factory to execute the Task
     */
    Thread thread=myFactory.newThread(task);
   
    /*
     * Start the Thread
     */
    thread.start();
 
View Full Code Here

Examples of com.packtpub.java7.concurrency.chapter7.recipe04.task.MyThreadFactory

  public static void main(String[] args) throws Exception {
   
    /*
     * Create a new MyThreadFactory object
     */
    MyThreadFactory threadFactory=new MyThreadFactory("MyThreadFactory");
   
    /*
     * Create a new ThreadPoolExecutor and configure it for use the
     * MyThreadFactoryObject created before as the factory to create the threads
     */
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.