diff options
| author | 2015-09-17 20:46:56 -0700 | |
|---|---|---|
| committer | 2015-09-18 10:59:39 -0700 | |
| commit | 72e36d84d8c6eb4a0396ce7e4de8f696ad3d2a7f (patch) | |
| tree | b0674ce1c1650c842e05f269585bb9ede2e26bbd | |
| parent | 10da8717e5e909556c7e7610d212db6c65fefbe2 (diff) | |
Handle OOME during threadstress finishing message
If there is an OOME that occurs after the "Finishing workers" it
caused the test to fail.
Also guard worker thread creation by try catch for OOME.
Bug: 18577101
Change-Id: I69367be0aad3f60093c02c7f63ae3c20757fb89b
| -rw-r--r-- | test/004-ThreadStress/src/Main.java | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/test/004-ThreadStress/src/Main.java b/test/004-ThreadStress/src/Main.java index 4eeae2f295..9461c0b967 100644 --- a/test/004-ThreadStress/src/Main.java +++ b/test/004-ThreadStress/src/Main.java @@ -443,13 +443,14 @@ public class Main implements Runnable { int id = threadStress.id; System.out.println("Starting worker for " + id); while (threadStress.nextOperation < operationsPerThread) { - Thread thread = new Thread(ts, "Worker thread " + id); - thread.start(); - try { - thread.join(); - } catch (InterruptedException e) { - } try { + Thread thread = new Thread(ts, "Worker thread " + id); + thread.start(); + try { + thread.join(); + } catch (InterruptedException e) { + } + System.out.println("Thread exited for " + id + " with " + (operationsPerThread - threadStress.nextOperation) + " operations remaining."); @@ -458,7 +459,14 @@ public class Main implements Runnable { // to pass. } } - System.out.println("Finishing worker"); + // Keep trying to print "Finishing worker" until it succeeds. + while (true) { + try { + System.out.println("Finishing worker"); + break; + } catch (OutOfMemoryError e) { + } + } } }; } |