File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,8 @@ public static class EvenPrinter implements Runnable {
6464 @ Override
6565 public void run () {
6666 while (number .num <= 100 ) {
67+ // if (Thread.currentThread().isInterrupted())
68+ // return;
6769 synchronized (number ) {
6870 try {
6971 Thread .sleep (300 );
@@ -94,6 +96,8 @@ public static class OddPrinter implements Runnable {
9496 @ Override
9597 public void run () {
9698 while (number .num <= 100 ) {
99+ // if (Thread.currentThread().isInterrupted())
100+ // return;
97101 synchronized (number ) {
98102 if (number .num % 2 != 0 ) {
99103 try {
@@ -133,5 +137,13 @@ public static void main(String[] args) {
133137 Thread oddThread = new Thread (oddPrinter );
134138 evenThread .start ();
135139 oddThread .start ();
140+ // try {
141+ // Thread.sleep(2000);
142+ // } catch (InterruptedException e) {
143+ // e.printStackTrace();
144+ // }
145+ // evenThread.interrupt();
146+ // oddThread.interrupt();
147+
136148 }
137149}
You can’t perform that action at this time.
0 commit comments