Package java.util.concurrent.locks

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


    public Endpoint getNextEndpoint(MessageContext synapseMessageContext,
                                    AlgorithmContext algorithmContext) {

        Lock readLock = lock.readLock();
        readLock.lock();
        try {
            if (!isThreadLocal) {
                synchronized (this) {
                    EndpointState state = endpointStates[endpointCursor];
                    if (state.getCurrentWeight() == 0) {
View Full Code Here


        });
    }

    public void changeWeight(int pos, int weight) {
        Lock writeLock = lock.writeLock();
        writeLock.lock();
        try {
            EndpointState state = null;
            for (EndpointState s : endpointStates) {
                if (s.getEndpointPosition() == pos) {
                    state = s;
View Full Code Here

                    UNICAST.UnicastHeader hdr=(UNICAST.UnicastHeader)((Message)evt.getArg()).getHeader(UNICAST_ID);
                    if(hdr != null)
                        delivered_msg_list.add(hdr.getSeqno());

                    if(delivered_msgs.get() >= num_msgs) {
                        lock.lock();
                        try {
                            all_msgs_delivered.signalAll();
                        }
                        finally {
                            lock.unlock();
View Full Code Here

        }

        long start=System.currentTimeMillis();
        latch.countDown(); // starts all adders

        lock.lock();
        try {
            while(delivered_msgs.get() < num_msgs) {
                try {
                    all_msgs_delivered.await(1000, TimeUnit.MILLISECONDS);
                    System.out.println("received " + delivered_msgs.get() + " msgs");
View Full Code Here

        router=new GossipRouter(12001, bind_addr);
        router.start();

        System.out.println("-- waiting for merge to happen --");
        long target_time=System.currentTimeMillis() + 40000;
        lock.lock();
        try {
            while(System.currentTimeMillis() < target_time && done.get() == false) {
                cond.await(1000, TimeUnit.MILLISECONDS);
            }
        }
View Full Code Here

                    UNICAST2.Unicast2Header hdr=(UNICAST2.Unicast2Header)((Message)evt.getArg()).getHeader(UNICAST_ID);
                    if(hdr != null)
                        delivered_msg_list.add(hdr.getSeqno());

                    if(delivered_msgs.get() >= num_msgs) {
                        lock.lock();
                        try {
                            all_msgs_delivered.signalAll();
                        }
                        finally {
                            lock.unlock();
View Full Code Here

        }

        long start=System.currentTimeMillis();
        latch.countDown(); // starts all adders

        lock.lock();
        try {
            while(delivered_msgs.get() < num_msgs) {
                try {
                    all_msgs_delivered.await(1000, TimeUnit.MILLISECONDS);
                    System.out.println("received " + delivered_msgs.get() + " msgs");
View Full Code Here

            throw new IllegalArgumentException();
        }
        int h0 = hash0(x);
        Lock lock0 = locks[0][h0 % LOCKS];
        try {
            lock0.lock();
            if(x.equals(table[0][h0])) {
                return true;
            } else {
                int h1 = hash1(x);
                Lock lock1 = locks[1][h1 % LOCKS];
View Full Code Here

                return true;
            } else {
                int h1 = hash1(x);
                Lock lock1 = locks[1][h1 % LOCKS];
                try {
                    lock1.lock();
                    if(x.equals(table[1][h1])) {
                        return true;
                    }
                    return false;
                } finally {
View Full Code Here

            throw new IllegalArgumentException();
        }
        int h0 = hash0(x);
        Lock lock0 = locks[0][h0 % LOCKS];
        try {
            lock0.lock();
            if(x.equals(table[0][h0])) {
                table[0][h0] = null;
                return true;
            } else {
                int h1 = hash1(x);
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.