Skip to content

Fix Deadlock from Thread.suspend in Test #39261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,18 @@ protected Pattern[] getUnsafeClasses() {
final LockedExecutor lockedExecutor = new LockedExecutor();
final AtomicLong ops = new AtomicLong();
final Thread[] threads = new Thread[5];
final Runnable yieldAndIncrement = () -> {
Thread.yield(); // give some chance to catch this stack trace
ops.incrementAndGet();
};
try {
for (int i = 0; i < threads.length; i++) {
threads[i] = new Thread(() -> {
for (int iter = 0; stop.get() == false; iter++) {
if (iter % 2 == 0) {
lockedExecutor.executeLocked(() -> {
Thread.yield(); // give some chance to catch this stack trace
ops.incrementAndGet();
});
lockedExecutor.executeLocked(yieldAndIncrement);
} else {
Thread.yield(); // give some chance to catch this stack trace
ops.incrementAndGet();
yieldAndIncrement.run();
}
}
});
Expand Down