-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Potential multi-threading issue in tests with timeouts #388
Comments
+1 I recommend to use volatile on fExceptionThrownByOriginalStatement as well . I would recommend you to redesign the constructor in order to initializing the volatile variables before final in the constructor to make sure that all are properly initialized before constructor freeze. The volatile needs write a dummy operation first even if false or null by the spec:
private final Statement fStatement;
private volatile boolean fFinished;
private volatile Throwable fExceptionThrownByOriginalStatement;
|
This is an old issue, but may be relatively easy to fix for someone looking for a chance to contribute. |
@dsaff is this still an issue as Thanks. |
@codingricky I think this issue was fixed, but the recent changes to |
The remaining issues were fixed in #765 |
FailOnTimeout.StatementThread.fFinished should be volatile since at least 2 threads access it: the main thread and StatementThread (which is started by main).
This is "to ensure that updates to a variable are propagated predictably to other threads" (Java Concurrency in Practice, 3.1.4, Joshua Bloch).
The text was updated successfully, but these errors were encountered: