summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Aart Bik <ajcbik@google.com> 2016-03-23 11:31:28 -0700
committer Aart Bik <ajcbik@google.com> 2016-03-23 14:41:52 -0700
commitd07453889fd9f314849df8c172afadb477e46d64 (patch)
tree7c8b2d9bace6f45622927e69a825222b3f103fd6
parent6fa06e6f5a92cd318021afad9b036126438b2de4 (diff)
Fix potential race condition with threads array.
Rationale: Array should be filled with threads prior to first fork, since only in that case does Java memory model ensure all threads have consistent view of array, which itself is subject to one test. BUG=27805463 Change-Id: I28f1eb8461842217ced2255062d2135ef880e7d5
-rw-r--r--test/004-checker-UnsafeTest18/src/Main.java4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/004-checker-UnsafeTest18/src/Main.java b/test/004-checker-UnsafeTest18/src/Main.java
index c50613d580..282f9ce0d0 100644
--- a/test/004-checker-UnsafeTest18/src/Main.java
+++ b/test/004-checker-UnsafeTest18/src/Main.java
@@ -133,6 +133,10 @@ public class Main {
private static void fork(Runnable r) {
for (int i = 0; i < 10; i++) {
sThreads[i] = new Thread(r);
+ }
+ // Start the threads only after the full array has been written with new threads,
+ // because one test relies on the contents of this array to be consistent.
+ for (int i = 0; i < 10; i++) {
sThreads[i].start();
}
}