1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/deadlock/src/org/apidesign/deadlock/logs/Parallel.java Sat Jun 14 09:54:32 2008 +0200
1.3 @@ -0,0 +1,25 @@
1.4 +package org.apidesign.deadlock.logs;
1.5 +
1.6 +import java.util.Random;
1.7 +import java.util.logging.Level;
1.8 +import java.util.logging.Logger;
1.9 +
1.10 +// BEGIN: test.parallel
1.11 +class Parael implements Runnable {
1.12 + public void run() {
1.13 + Random r = new Random();
1.14 + for (int i = 0; i < 10; i++) {
1.15 + try {
1.16 + Thread.sleep(r.nextInt(100));
1.17 + } catch (InterruptedException ex) {}
1.18 + Logger.global.log(Level.WARNING, "cnt: {0}", new Integer(i));
1.19 + }
1.20 + }
1.21 + public static void main(String[] args) throws InterruptedException {
1.22 + Thread t1 = new Thread(new Parael(), "1st");
1.23 + Thread t2 = new Thread(new Parael(), "2nd");
1.24 + t1.start(); t2.start();
1.25 + t1.join(); t2.join();
1.26 + }
1.27 +}
1.28 +// END: test.parallel