Package com.packtpub.java7.concurrency.chapter4.recipe7.task

Examples of com.packtpub.java7.concurrency.chapter4.recipe7.task.Task


      Thread thread=new Thread(writer);
      thread.start();
    }
   
    // Creates a cleaner task and starts them
    CleanerTask cleaner=new CleanerTask(deque);
    cleaner.start();

  }
View Full Code Here


   * Main method of the example
   * @param args
   */
  public static void main(String[] args) {
    // Creates a task
    SafeTask task=new SafeTask();
   
    // Creates and start three Thread objects for that Task
    for (int i=0; i<3; i++){
      Thread thread=new Thread(task);
      try {
View Full Code Here

   * three Thread objects that run it.
   * @param args
   */
  public static void main(String[] args) {
    // Creates the unsafe task
    UnsafeTask task=new UnsafeTask();
   
    // Throw three Thread objects
    for (int i=0; i<3; i++){
      Thread thread=new Thread(task);
      thread.start();
View Full Code Here

   
    // Creates the Event data structure
    Deque<Event> deque=new ArrayDeque<Event>();
   
    // Creates the three WriterTask and starts them
    WriterTask writer=new WriterTask(deque);
    for (int i=0; i<3; i++){
      Thread thread=new Thread(writer);
      thread.start();
    }
   
View Full Code Here

   * exception
   * @param args
   */
  public static void main(String[] args) {
    // Creates the Task
    Task task=new Task();
    // Creates the Thread
    Thread thread=new Thread(task);
    // Sets de uncaugh exceptio handler
    thread.setUncaughtExceptionHandler(new ExceptionHandler());
    // Starts the Thread
View Full Code Here

   * Main method of the example
   * @param args
   */
  public static void main(String[] args) {
    // Creates a new account ...
    Account  account=new Account();
    // an initialize its balance to 1000
    account.setBalance(1000);
   
    // Creates a new Company and a Thread to run its task
    Company  company=new Company(account);
    Thread companyThread=new Thread(company);
    // Creates a new Bank and a Thread to run its task
    Bank bank=new Bank(account);
    Thread bankThread=new Thread(bank);
   
    // Prints the initial balance
    System.out.printf("Account : Initial Balance: %f\n",account.getBalance());
   
    // Starts the Threads
    companyThread.start();
    bankThread.start();

    try {
      // Wait for the finalization of the Threads
      companyThread.join();
      bankThread.join();
      // Print the final balance
      System.out.printf("Account : Final Balance: %f\n",account.getBalance());
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

   * Main method of the example
   * @param args
   */
  public static void main(String[] args) {
    // Creates a new account ...
    Account  account=new Account();
    // an initialize its balance to 1000
    account.setBalance(1000);
   
    // Creates a new Company and a Thread to run its task
    Company  company=new Company(account);
    Thread companyThread=new Thread(company);
    // Creates a new Bank and a Thread to run its task
    Bank bank=new Bank(account);
    Thread bankThread=new Thread(bank);
   
    // Prints the initial balance
    System.out.printf("Account : Initial Balance: %f\n",account.getBalance());
   
    // Starts the Threads
    companyThread.start();
    bankThread.start();

    try {
      // Wait for the finalization of the Threads
      companyThread.join();
      bankThread.join();
      // Print the final balance
      System.out.printf("Account : Final Balance: %f\n",account.getBalance());
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

   
    // Creates a new Company and a Thread to run its task
    Company  company=new Company(account);
    Thread companyThread=new Thread(company);
    // Creates a new Bank and a Thread to run its task
    Bank bank=new Bank(account);
    Thread bankThread=new Thread(bank);
   
    // Prints the initial balance
    System.out.printf("Account : Initial Balance: %f\n",account.getBalance());
   
View Full Code Here

   
    // Creates a new Company and a Thread to run its task
    Company  company=new Company(account);
    Thread companyThread=new Thread(company);
    // Creates a new Bank and a Thread to run its task
    Bank bank=new Bank(account);
    Thread bankThread=new Thread(bank);
   
    // Prints the initial balance
    System.out.printf("Account : Initial Balance: %f\n",account.getBalance());
   
View Full Code Here

    Account  account=new Account();
    // an initialize its balance to 1000
    account.setBalance(1000);
   
    // Creates a new Company and a Thread to run its task
    Company  company=new Company(account);
    Thread companyThread=new Thread(company);
    // Creates a new Bank and a Thread to run its task
    Bank bank=new Bank(account);
    Thread bankThread=new Thread(bank);
   
View Full Code Here

TOP

Related Classes of com.packtpub.java7.concurrency.chapter4.recipe7.task.Task

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.