Package com.packtpub.java7.concurrency.chapter6.recipe07.core

Examples of com.packtpub.java7.concurrency.chapter6.recipe07.core.Main


   
    // Create a ForkJoinPool with the default constructor
    ForkJoinPool pool=new ForkJoinPool();
   
    // Create a Task to process the array
    SearchNumberTask task=new SearchNumberTask(array,0,1000,5,manager);
   
    // Execute the task
    pool.execute(task);

    // Shutdown the pool
View Full Code Here


   * @param args
   */
  public static void main(String[] args) {

    // Generate an array of 1000 integers
    ArrayGenerator generator=new ArrayGenerator();
    int array[]=generator.generateArray(1000);
   
    // Create a TaskManager object
    TaskManager manager=new TaskManager();
   
    // Create a ForkJoinPool with the default constructor
View Full Code Here

    // Generate an array of 1000 integers
    ArrayGenerator generator=new ArrayGenerator();
    int array[]=generator.generateArray(1000);
   
    // Create a TaskManager object
    TaskManager manager=new TaskManager();
   
    // Create a ForkJoinPool with the default constructor
    ForkJoinPool pool=new ForkJoinPool();
   
    // Create a Task to process the array
View Full Code Here

    OneSecondLongTask task=new OneSecondLongTask();
   
    // Creates a new Handler
    Handler handler = new Handler();
    // Creates a Factory
    AlwaysThrowsExceptionWorkerThreadFactory factory=new AlwaysThrowsExceptionWorkerThreadFactory();
    // Creates a new ForkJoinPool
    ForkJoinPool pool=new ForkJoinPool(2,factory,handler,false);
   
    // Execute the task in the pool
    pool.execute(task);
View Full Code Here

    // Creates a task
    OneSecondLongTask task=new OneSecondLongTask();
   
    // Creates a new Handler
    Handler handler = new Handler();
    // Creates a Factory
    AlwaysThrowsExceptionWorkerThreadFactory factory=new AlwaysThrowsExceptionWorkerThreadFactory();
    // Creates a new ForkJoinPool
    ForkJoinPool pool=new ForkJoinPool(2,factory,handler,false);
   
View Full Code Here

   * @param args
   */
  public static void main(String[] args) {

    // Creates a task
    OneSecondLongTask task=new OneSecondLongTask();
   
    // Creates a new Handler
    Handler handler = new Handler();
    // Creates a Factory
    AlwaysThrowsExceptionWorkerThreadFactory factory=new AlwaysThrowsExceptionWorkerThreadFactory();
View Full Code Here

    // Create an Array of 100 threads
    Thread threads[]=new Thread[100];

    // Create 100 AddTask objects and execute them as threads
    for (int i=0; i<threads.length; i++){
      AddTask task=new AddTask(list);
      threads[i]=new Thread(task);
      threads[i].start();
    }
    System.out.printf("Main: %d AddTask threads have been launched\n",threads.length);
   
View Full Code Here

    // Write to the console the size of the list
    System.out.printf("Main: Size of the List: %d\n",list.size());
   
    // Create 100 PollTask objects and execute them as threads
    for (int i=0; i<threads.length; i++){
      PollTask task=new PollTask(list);
      threads[i]=new Thread(task);
      threads[i].start();
    }
    System.out.printf("Main: %d PollTask threads have been launched\n",threads.length);
   
View Full Code Here

  public static void main(String[] args) throws Exception {

    // Create a ConcurrentLinkedDeque to work with it in the example
    LinkedBlockingDeque<String> list=new LinkedBlockingDeque<>(3);
   
    Client client=new Client(list);
    Thread thread=new Thread(client);
    thread.start();
   
    for (int i=0; i<5 ; i++) {
      for (int j=0; j<3; j++) {
View Full Code Here

   
    /*
     * Launch 100 Consumer tasks
     */
    for (int i=0; i<THREADS; i++){
      Consumer consumer=new Consumer("Consumer "+i,buffer);
      consumerThreads[i]=new Thread(consumer);
      consumerThreads[i].start();
    }
   
    /*
 
View Full Code Here

TOP

Related Classes of com.packtpub.java7.concurrency.chapter6.recipe07.core.Main

Copyright © 2018 www.massapicom. 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.