Package thread.concurrencyCookbook.chapter4.recipe12

Examples of thread.concurrencyCookbook.chapter4.recipe12.RejectedTaskController


   * 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


   */
  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++){
View Full Code Here

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

    // Create the controller for the Rejected tasks
    RejectedTaskController controller=new RejectedTaskController();
    // Create the executor and establish the controller for the Rejected tasks
    ThreadPoolExecutor executor=(ThreadPoolExecutor)Executors.newCachedThreadPool();
    executor.setRejectedExecutionHandler(controller);
   
    // Lauch three tasks
View Full Code Here

    executor.setRejectedExecutionHandler(controller);
   
    // Lauch three tasks
    System.out.printf("Main: Starting.\n");
    for (int i=0; i<3; i++) {
      Task task=new Task("Task"+i);
      executor.submit(task);
    }
   
    // Shutdown the executor
    System.out.printf("Main: Shuting down the Executor.\n");
    executor.shutdown();

    // Send another task
    System.out.printf("Main: Sending another Task.\n");
    Task task=new Task("RejectedTask");
    executor.submit(task);
   
    // The program ends
    System.out.printf("Main: End.\n");
   
View Full Code Here

TOP

Related Classes of thread.concurrencyCookbook.chapter4.recipe12.RejectedTaskController

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.