Package com.packtpub.java7.concurrency.chapter1.recipe12.task

Examples of com.packtpub.java7.concurrency.chapter1.recipe12.task.Task


   * 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

    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

    PrintQueue printQueue=new PrintQueue();
   
    // Creates ten Threads
    Thread thread[]=new Thread[10];
    for (int i=0; i<10; i++){
      thread[i]=new Thread(new Job(printQueue),"Thread "+i);
    }
   
    // Starts the Threads
    for (int i=0; i<10; i++){
      thread[i].start();
View Full Code Here

   * send documents to the print queue at the same time.
   */
  public static void main (String args[]){
   
    // Creates the print queue
    PrintQueue printQueue=new PrintQueue();
   
    // Creates ten Threads
    Thread thread[]=new Thread[10];
    for (int i=0; i<10; i++){
      thread[i]=new Thread(new Job(printQueue),"Thread "+i);
View Full Code Here

   
    // Initializes the object for the results
    Results results=new Results(ROWS);
   
    // Creates an Grouper object
    Grouper grouper=new Grouper(results);
   
    // Creates the CyclicBarrier object. It has 5 participants and, when
    // they finish, the CyclicBarrier will execute the grouper object
    CyclicBarrier barrier=new CyclicBarrier(PARTICIPANTS,grouper);
   
View Full Code Here

TOP

Related Classes of com.packtpub.java7.concurrency.chapter1.recipe12.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.