Skip to content

Commit

Permalink
add an interrupt test case
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyiteng committed Dec 18, 2019
1 parent 9c28b84 commit 3ee3537
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/isolated/InterruptTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
public class InterruptTest {
public static void main(String args[]) {
Thread current = Thread.currentThread();
System.out.println(current.isInterrupted());
current.interrupt();
System.out.println(current.isInterrupted());
System.out.println(current.isInterrupted());
System.out.println(Thread.interrupted());
System.out.println(current.isInterrupted());
current.interrupt();
synchronized (current) {
try {
current.wait(1);
System.out.println("no");
} catch (InterruptedException e) {
System.out.println(e.getClass());
}
}
synchronized (current) {
try {
current.wait(1);
System.out.println("yes");
} catch (InterruptedException e) {
System.out.println(e.getClass());
}
}
current.interrupt();
synchronized (current) {
try {
current.join();
System.out.println("yes");
} catch (InterruptedException e) {
System.out.println(e.getClass());
}
}
}
}

0 comments on commit 3ee3537

Please sign in to comment.