Package java.util.concurrent.locks

Examples of java.util.concurrent.locks.Lock.lock()


        final Lock runLock = new ReentrantLock();
        final Condition runCondition = runLock.newCondition();
        long start = System.currentTimeMillis();
        Runnable doNothing = new Runnable() {
            public void run() {
                runLock.lock();
                try {
                    runCondition.signal();
                } finally {
                    runLock.unlock();
                }
View Full Code Here


            }
        };
       
        workqueue.schedule(doNothing, 5000);
       
        runLock.lock();
        try {
            runCondition.await();
        } finally {
            runLock.unlock();
        }
View Full Code Here

  private void asyncSetState(final Collection<INews> news, final State state, final boolean affectEquivalentNews, final boolean force) throws PersistenceException {
    if (news.isEmpty())
      return;
    final NewsEventRunnable eventRunnable = new NewsEventRunnable();;
    final Lock setStateLock = new ReentrantLock();
    setStateLock.lock();
    final Condition condition = setStateLock.newCondition();
    fExecutorService.execute(new Runnable() {
      public void run() {
        Set<INews> changedNews = null;
        try {
View Full Code Here

    fExecutorService.execute(new Runnable() {
      public void run() {
        Set<INews> changedNews = null;
        try {
          fWriteLock.lock();
          setStateLock.lock();

          if (affectEquivalentNews) {
            /*
             * Give extra 25% size to take into account news that have same guid or
             * link.
 
View Full Code Here

        // TODO: manage lock per method and read or write lock !
        // for now, use only write lock

        // acquire lock
        Lock writeLock = this.lock.writeLock();
        writeLock.lock();

        try {
            value = m.invoke(bean, localCallRequest.getMethodArgs());
        } catch (IllegalArgumentException e) {
            ejbResponse.setRPCException(new RPCException(e));
View Full Code Here

    StateChangeListener listener = new StateChangeListener()
    {

      public void stateChange(int newState, int oldState)
      {
        lock.lock();
        isIdle.signal();
        lock.unlock();
      }

    };
View Full Code Here

    };
    this.addStateChangeListener(STATE_IDLE, listener);
    if (_state != STATE_IDLE)
      try
      {
        lock.lock();
        isIdle.await(t, TimeUnit.MILLISECONDS);
      }
      catch (InterruptedException e)
      {
        e.printStackTrace();
View Full Code Here

    wsform._GO_BUTTON.addActionListener(new ActionListener()
    {

      public void actionPerformed(ActionEvent e)
      {
        lock.lock();
        cont.signal();
        lock.unlock();
      }

    });
View Full Code Here

    });

    showStep("Click button to continue");

    // wait for continue button
    lock.lock();
    cont.await();
    lock.unlock();

    // get user data
    destination = wsform._INSTALL_FOLDER.getText();
View Full Code Here

    public void testWithLocking() {
        ReentrantReadWriteLock readWriteLock = dhns.getReadWriteLock();
        Lock lock = readWriteLock.readLock();

        for (int i = 0; i < 100000; i++) {
            lock.lock();
            int degree = singleNode.getEdgesInTree().getCount() + singleNode.getEdgesOutTree().getCount();
            lock.unlock();
        }
    }
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.