Package thread.concurrencyCookbook.chapter3.recipe5

Examples of thread.concurrencyCookbook.chapter3.recipe5.Main


   * @param args
   */
  public static void main(String[] args) {
    // Creates a FileClock runnable object and a Thread
    // to run it
    FileClock clock=new FileClock();
    Thread thread=new Thread(clock);
   
    // Starts the Thread
    thread.start();
    try {
View Full Code Here


    PrintQueue printQueue=new PrintQueue();
   
    // Cretes ten jobs and the Threads to run them
    Thread thread[]=new Thread[10];
    for (int i=0; i<10; i++){
      thread[i]=new Thread(new Job(printQueue),"Thread "+i);
    }
   
    // Launch a thread ever 0.1 seconds
    for (int i=0; i<10; i++){
      thread[i].start();
View Full Code Here

   * Main method of the example
   * @param args
   */
  public static void main (String args[]){
    // Creates the print queue
    PrintQueue printQueue=new PrintQueue();
   
    // Cretes ten jobs and the Threads to run them
    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

   
    // Creates a Phaser with three participants
    Phaser phaser=new Phaser(3);
   
    // Creates 3 FileSearch objects. Each of them search in different directory
    FileSearch system=new FileSearch("C:\\Windows", "log", phaser);
    FileSearch apps=new FileSearch("C:\\Program Files","log",phaser);
    FileSearch documents=new FileSearch("C:\\Documents And Settings","log",phaser);
   
    // Creates a thread to run the system FileSearch and starts it
    Thread systemThread=new Thread(system,"System");
    systemThread.start();
   
View Full Code Here

    // Create two user validation objects
    UserValidator ldapValidator=new UserValidator("LDAP");
    UserValidator dbValidator=new UserValidator("DataBase");
   
    // Create two tasks for the user validation objects
    TaskValidator ldapTask=new TaskValidator(ldapValidator, username, password);
    TaskValidator dbTask=new TaskValidator(dbValidator,username,password);
   
    // Add the two tasks to a list of tasks
    List<TaskValidator> taskList=new ArrayList<>();
    taskList.add(ldapTask);
    taskList.add(dbTask);
View Full Code Here

    // Initialize the parameters of the user
    String username="test";
    String password="test";
   
    // Create two user validation objects
    UserValidator ldapValidator=new UserValidator("LDAP");
    UserValidator dbValidator=new UserValidator("DataBase");
   
    // Create two tasks for the user validation objects
    TaskValidator ldapTask=new TaskValidator(ldapValidator, username, password);
    TaskValidator dbTask=new TaskValidator(dbValidator,username,password);
   
View Full Code Here

TOP

Related Classes of thread.concurrencyCookbook.chapter3.recipe5.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.