Package java.util.concurrent.locks

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



    @Override
    public WebResourceRoot getResources() {
        Lock readLock = resourcesLock.readLock();
        readLock.lock();
        try {
            return resources;
        } finally {
            readLock.unlock();
        }
View Full Code Here


    @Override
    public void setResources(WebResourceRoot resources) {

        Lock writeLock = resourcesLock.writeLock();
        writeLock.lock();
        WebResourceRoot oldResources = null;
        try {
            if (getState().isAvailable()) {
                throw new IllegalStateException
                    (sm.getString("standardContext.resources.started"));
View Full Code Here

    public boolean resourcesStop() {

        boolean ok = true;

        Lock writeLock = resourcesLock.writeLock();
        writeLock.lock();
        try {
            if (resources != null) {
                resources.stop();
            }
        } catch (Throwable t) {
View Full Code Here

     * therefore uses a lock to close the connection in a thread-safe manner.
     */
    private void closeConnection(String reason) throws AMQException
    {
        Lock receivedLock = _session.getReceivedLock();
        receivedLock.lock();
        try
        {
            _session.close(AMQConstant.RESOURCE_ERROR, reason);
        }
        finally
View Full Code Here

      throw new RuntimeException(msg);
    }
    int srcIndex = 0, cnt = -1;
    for (int i = startBuffer; i <= endBuffer; ++i) {
      Lock lock = locks[i];
      lock.lock();
      try {
        ByteBuffer bb = buffers[i];
        if (i == startBuffer) {
          cnt = bufferSize - startOffset;
          if (cnt > len) cnt = len;
View Full Code Here

            int i = -1;

            try {

                final Lock l1 = this.lock;
                l1.lock();

                try {
                    if (!KeepAliveServer.this.gzip) {
                        in = new BufferedInputStream(socket.getInputStream());
                        out = new BufferedOutputStream(socket.getOutputStream());
View Full Code Here

                        break;
                    }
                    final KeepAliveStyle style = KeepAliveStyle.values()[i];

                    final Lock l2 = this.lock;
                    l2.lock();

                    try {

                        switch (style) {
                            case PING_PING: {
View Full Code Here

        @SuppressWarnings("unchecked")
        public boolean add(final URI o) {

            final Lock lock = sync.writeLock();
            lock.lock();

            try {
                ClusterMetaData nextVersion = null;
                try {
                    if (set.add(o)) {
View Full Code Here

            }
        }

        public boolean remove(final Object o) {
            final Lock lock = sync.writeLock();
            lock.lock();

            try {
                ClusterMetaData nextVersion = null;
                try {
                    if (set.remove(o)) {
View Full Code Here

            return new ClusterMetaData(System.currentTimeMillis(), locations);
        }

        public ClusterMetaData current() {
            final Lock lock = sync.readLock();
            lock.lock();
            try {
                return current.get();
            } finally {
                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.