Blob Blame History Raw
From c884a17bfaa3f3ff4a802b3de9e06d48c494eb68 Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Tue, 5 Nov 2013 14:00:03 +0100
Subject: [PATCH 04/39] Make thread stress test more robust

Related to #21
Related to rhbz#1051483
---
 test/ThreadStressTest.java | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/test/ThreadStressTest.java b/test/ThreadStressTest.java
index 3ebf9e0..981ba91 100644
--- a/test/ThreadStressTest.java
+++ b/test/ThreadStressTest.java
@@ -46,22 +46,29 @@ public class ThreadStressTest {
 
         List<Thread> tojoin = new LinkedList<Thread>();
 
-        for (int i = 100; i != 0; --i) {
-            for (int j = 300; j != 0; --j) {
-                Thread t = new ThreadCaughtException();
-                tojoin.add(t);
-                System.out.println("Starting Thread: " + Integer.toString((i * j) + j));
-                t.start();
+        for (int i = 60; i != 0; --i) {
+            for (int j = 600; j != 0; --j) {
+                try {
+                    Thread t = new ThreadCaughtException();
+                    tojoin.add(t);
+                    System.out.println("Starting Thread: " + Integer.toString((i * j) + j));
+                    t.start();
+                }
+                catch(Throwable t) {
+                    System.out.println("Thread start: " + t.toString());
+                    System.exit(1);
+                }
             }
 
             try {
-                Thread.currentThread().sleep(1000);
+                Thread.currentThread().sleep(500);
             }
             catch (InterruptedException ex) {
                 System.out.println("Interrupted");
             }
         }
 
+        System.out.println("All Threads Started");
         for (Thread t : tojoin) {
             try {
                 t.join();
@@ -71,6 +78,7 @@ public class ThreadStressTest {
             }
         }
 
+        System.out.println("All Threads Finished");
         System.exit(0);
     }
 }
-- 
1.8.3.1