samples/deadlock/src/org/apidesign/deadlock/logs/Parallel.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 09:54:32 +0200
changeset 108 a420a1124988
child 203 0e46110eebc1
permissions -rw-r--r--
Enough of logging, Jesse will anyway advice to delete this part
     1 package org.apidesign.deadlock.logs;
     2 
     3 import java.util.Random;
     4 import java.util.logging.Level;
     5 import java.util.logging.Logger;
     6 
     7 // BEGIN: test.parallel
     8 class Parael implements Runnable {
     9     public void run() {
    10         Random r = new Random();
    11         for (int i = 0; i < 10; i++) {
    12             try {
    13                 Thread.sleep(r.nextInt(100));
    14             } catch (InterruptedException ex) {}
    15             Logger.global.log(Level.WARNING, "cnt: {0}", new Integer(i));
    16         }
    17     }
    18     public static void main(String[] args) throws InterruptedException {
    19         Thread t1 = new Thread(new Parael(), "1st");
    20         Thread t2 = new Thread(new Parael(), "2nd");
    21         t1.start(); t2.start();
    22         t1.join(); t2.join();
    23     }
    24 }
    25 // END: test.parallel