equal
deleted
inserted
replaced
42 */ |
42 */ |
43 public class TestStart { |
43 public class TestStart { |
44 static class StartEvent extends Event { |
44 static class StartEvent extends Event { |
45 } |
45 } |
46 static class EventProducer extends Thread { |
46 static class EventProducer extends Thread { |
|
47 private final Object lock = new Object(); |
47 private boolean killed = false; |
48 private boolean killed = false; |
48 public void run() { |
49 public void run() { |
49 while (true) { |
50 while (true) { |
50 StartEvent s = new StartEvent(); |
51 StartEvent s = new StartEvent(); |
51 s.commit(); |
52 s.commit(); |
52 synchronized (this) { |
53 synchronized (lock) { |
53 try { |
54 try { |
54 wait(10); |
55 lock.wait(10); |
55 if (killed) { |
56 if (killed) { |
56 return; // end thread |
57 return; // end thread |
57 } |
58 } |
58 } catch (InterruptedException e) { |
59 } catch (InterruptedException e) { |
59 // ignore |
60 // ignore |
60 } |
61 } |
61 } |
62 } |
62 } |
63 } |
63 } |
64 } |
64 public void kill() { |
65 public void kill() { |
65 synchronized (this) { |
66 synchronized (lock) { |
66 this.killed = true; |
67 this.killed = true; |
67 this.notifyAll(); |
68 lock.notifyAll(); |
68 } |
69 } |
69 } |
70 } |
70 } |
71 } |
71 |
72 |
72 public static void main(String... args) throws Exception { |
73 public static void main(String... args) throws Exception { |