Package java.util.concurrent

Examples of java.util.concurrent.Semaphore.release()


               // log("passed barrier");
               lock = s.readLock();
               lock.tryLock(TIMEOUT, TimeUnit.MILLISECONDS);
               log("1st read: value is " + value);
               assertEquals(10, value);
               sem.release(); // give t2 time to make the modification
               TestingUtil.sleepThread(100);

               sem.acquire(); // to read the uncommitted modification by t2
               log("2nd read: value is " + value + "; we should see t2's uncommitted change (20)");
               assertEquals(20, value); // we're seeing the modification by t2 before t2 committed (a.k.a. released the lock)
View Full Code Here


               TestingUtil.sleepThread(100);

               sem.acquire(); // to read the uncommitted modification by t2
               log("2nd read: value is " + value + "; we should see t2's uncommitted change (20)");
               assertEquals(20, value); // we're seeing the modification by t2 before t2 committed (a.k.a. released the lock)
               sem.release();
               TestingUtil.sleepThread(100);

               sem.acquire(); // to read the committed change by t2
               log("3rd read: value is still " + value + "; we should see t2's committed change");
               assertEquals(20, value);
View Full Code Here

            }
            finally
            {
               if (lock != null)
                  lock.unlock();
               sem.release();
            }
         }
      };

View Full Code Here

               sem.acquire();
               lock = s.writeLock();
               lock.tryLock(TIMEOUT, TimeUnit.MILLISECONDS);
               log("changing value from " + value + " to 20");
               value = 20;
               sem.release(); // now t1 can read the uncommitted modification
               TestingUtil.sleepThread(100);

               sem.acquire(); // to unlock the lock
               log("committing the TX");
               lock.unlock();
View Full Code Here

            }
            finally
            {
               if (lock != null)
                  lock.unlock();
               sem.release();
            }
         }
      };

      t1.start();
View Full Code Here

                if (sipStack.getStackLogger().isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
                  sipStack.getStackLogger().logDebug("releasing semaphore for message " + message + " threadname " + mythread.getName());
                }
                //release the semaphore so that another thread can process another message from the call id queue in the correct order
                // or a new message from another call id queue
                semaphore.release();
                if(messagesOrderingMap.isEmpty()) {
                    synchronized (messagesOrderingMap) {
                        messagesOrderingMap.notify();
                    }
                }
View Full Code Here

  */

  private void leaveIOCriticalSection(String key) {
        Semaphore creationSemaphore = socketCreationMap.get(key);
        if (creationSemaphore != null) {
            creationSemaphore.release();
        }
    }

    private void enterIOCriticalSection(String key) throws IOException {
        // http://dmy999.com/article/34/correct-use-of-concurrenthashmap
View Full Code Here

                        ((Semaphore) ctx).release();
                    }
                }, latch);

                latch.acquire();
                latch.release();
                if (failureException != null) {
                    throw (Exception) failureException.getCause();
                }
            }
            List<Message> msgs = HelperMethods.getRandomPublishedMessages(NUM_MESSAGES_TO_TEST, 1024);
View Full Code Here

            Watcher watcher = new Watcher()
            {
                @Override
                public void process(WatchedEvent arg0)
                {
                    semaphore.release();
                }
            };
            client.checkExists().usingWatcher(watcher).forPath(PATH);
            node.setData("b".getBytes());
            Assert.assertTrue(timing.acquireSemaphore(semaphore));
View Full Code Here

                for (int i = 0; running.get(); i++) {
                    try {
                        NodeBuilder a = store.getRoot().builder();
                        a.setProperty("foo", "abc" + i);
                        store.merge(a, EmptyHook.INSTANCE, PostCommitHook.EMPTY);
                        semaphore.release();
                    } catch (CommitFailedException e) {
                        fail();
                    }
                }
            }
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.