Skip to content

Commit 2d1dc7f

Browse files
committed
ok
1 parent 8babc9d commit 2d1dc7f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/com/leetcode/ThreadTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)