Package java.util.concurrent.atomic

Examples of java.util.concurrent.atomic.AtomicInteger.wait()


                                                {
                                                    throw new TimeoutException();
                                                }
                                                while ( available.get() == 0 )
                                                {
                                                    available.wait(timing.forWaiting().milliseconds());
                                                }

                                                thisQty = (available.get() > 1) ? (random.nextInt(available.get()) + 1) : 1;

                                                available.addAndGet(-1 * thisQty);
 
View Full Code Here


      synchronized (counter)
      {
         service_.queueTask(new ATask(counter));
         service_.queueTask(new ATask(counter));
         service_.queueTask(new ATask(counter));
         counter.wait(30000);
      }
      assertEquals("expect a task is run 3 times", 3, 3 - counter.get());
      boolean b = service_.removeGlobaTriggerListener("GlobalTriggerListener");
      assertTrue("expect Global Trigger Listener is removed", b);
   }
View Full Code Here

            });
        }
        groups.get(0).broadcastMessage("hello");
        synchronized (count) {
            if (count.get() < number) {
                count.wait(5000);
            }
        }
        assertEquals(number, count.get());
        for (Group map : groups) {
            map.stop();
View Full Code Here

            });
        }
        groups.get(0).sendMessage("hello");
        synchronized (count) {
            if (count.get() == 0) {
                count.wait(5000);
            }
        }
        // wait a while to check that only one got it
        Thread.sleep(2000);
        assertEquals(1, count.get());
View Full Code Here

           
        });
        map1.start();
        synchronized(counter) {
            if (counter.get()<1) {
                counter.wait(5000);
            }
        }
        assertEquals(1, counter.get());
        Group map2 = new Group(connection2,"map2");
        map2.start();
View Full Code Here

        assertEquals(1, counter.get());
        Group map2 = new Group(connection2,"map2");
        map2.start();
        synchronized(counter) {
            if (counter.get()<2) {
                counter.wait(5000);
            }
        }
        assertEquals(2, counter.get());
        map2.stop();
        synchronized(counter) {
View Full Code Here

        }
        assertEquals(2, counter.get());
        map2.stop();
        synchronized(counter) {
            if (counter.get()>=2) {
                counter.wait(Group.DEFAULT_HEART_BEAT_INTERVAL*3);
            }
        }
        assertEquals(1, counter.get());
        map1.stop();
    }
View Full Code Here

            getConnection().start();
            LOG.info("Starting to asynchronously receive " + client.getRecvCount() + " messages...");
            try {
                while (recvCount.get() < count) {
                    synchronized (recvCount) {
                        recvCount.wait();
                    }
                }
            } catch (InterruptedException e) {
                throw new JMSException("JMS consumer thread wait has been interrupted. Message: " + e.getMessage());
            }
View Full Code Here

            long start = System.currentTimeMillis();
            while (count.get() < number) {
                if (waitTime <= 0) {
                    break;
                } else {
                    count.wait(waitTime);
                    waitTime = maxWaitTime - (System.currentTimeMillis() - start);
                }
            }
        }
        assertTrue("Unexpected count: " + count, count.get() == number);
View Full Code Here

            dialog.setVisible(true);
          }
        });
        synchronized (answer) {
          while(answer.get() == AbstractOracle.USER_WAITINGFORSELECTION)
              answer.wait();// wait for a user to make a response
        }
      } catch (InvocationTargetException e) {
        //e.printStackTrace();
        // if we cannot make a call, return a negative number - nothing do not know what else to do about it.
      }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.