changeset 34:72b9e96ddbe9

6595669: regtest LinkedBlockingQueue/OfferRemoveLoops.java fails Reviewed-by: dholmes
author martin
date Mon, 10 Mar 2008 23:23:47 -0700
parents 7ddbf4c837b9
children 3654a4ce7d54
files test/java/util/concurrent/LinkedBlockingQueue/OfferRemoveLoops.java
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/util/concurrent/LinkedBlockingQueue/OfferRemoveLoops.java	Mon Mar 10 23:23:47 2008 -0700
+++ b/test/java/util/concurrent/LinkedBlockingQueue/OfferRemoveLoops.java	Mon Mar 10 23:23:47 2008 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6316155
+ * @bug 6316155 6595669
  * @summary Test concurrent offer vs. remove
  * @author Martin Buchholz
  */
@@ -50,15 +50,18 @@
     private static void testQueue(final BlockingQueue<String> q) throws Throwable {
         System.out.println(q.getClass());
         final int count = 10000;
+        final long quittingTime = System.nanoTime() + 1L * 1000L * 1000L * 1000L;
         Thread t1 = new ControlledThread() {
                 protected void realRun() {
                     for (int i = 0, j = 0; i < count; i++)
-                        while (! q.remove(String.valueOf(i)))
+                        while (! q.remove(String.valueOf(i))
+                               && System.nanoTime() - quittingTime < 0)
                             Thread.yield();}};
         Thread t2 = new ControlledThread() {
                 protected void realRun() {
                     for (int i = 0, j = 0; i < count; i++)
-                        while (! q.offer(String.valueOf(i)))
+                        while (! q.offer(String.valueOf(i))
+                               && System.nanoTime() - quittingTime < 0)
                             Thread.yield();}};
         t1.setDaemon(true); t2.setDaemon(true);
         t1.start(); t2.start();