Package EDU.oswego.cs.dl.util.concurrent

Examples of EDU.oswego.cs.dl.util.concurrent.SynchronizedInt


      messageRefs = new BasicPriorityLinkedList(10);

      lock = new Object();

      deliveringCount = new SynchronizedInt(0);

      scheduledDeliveries = new HashSet();

      this.maxSize = maxSize;

      messagesAdded = new SynchronizedInt(0);
   }
View Full Code Here


        this.password = thePassword;
        this.clientIdGenerator = new IdGenerator();
        this.packetIdGenerator = new IdGenerator();
        this.handleIdGenerator = new IdGenerator();
        this.sessionIdGenerator = new IdGenerator();
        this.consumerNumberGenerator = new SynchronizedInt(0);
        this.sessions = new CopyOnWriteArrayList();
        this.messageDispatchers = new CopyOnWriteArrayList();
        this.connectionConsumers = new CopyOnWriteArrayList();
        this.connectionMetaData = new ActiveMQConnectionMetaData();
        this.started = new SynchronizedBoolean(false);
View Full Code Here

        this.password = thePassword;
        this.clientIdGenerator = new IdGenerator();
        this.packetIdGenerator = new IdGenerator();
        this.handleIdGenerator = new IdGenerator();
        this.sessionIdGenerator = new IdGenerator();
        this.consumerNumberGenerator = new SynchronizedInt(0);
        this.sessions = new CopyOnWriteArrayList();
        this.messageDispatchers = new CopyOnWriteArrayList();
        this.connectionConsumers = new CopyOnWriteArrayList();
        this.connectionMetaData = new ActiveMQConnectionMetaData();
        this.closed = new SynchronizedBoolean(false);
View Full Code Here

    /**
     * Construct the NetworkMessageConsumer
     */
    public NetworkMessageBridge() {
        this.referenceCount = new SynchronizedInt(0);
    }
View Full Code Here

        queueConnection.start();
    }

    public void testTemporaryQueueConsumer() throws Exception {
        final int NUMBER = 20;
        final SynchronizedInt count = new SynchronizedInt(0);
        for (int i = 0;i < NUMBER;i++) {
            Thread thread = new Thread(new Runnable() {
                public void run() {
                    try {
                        QueueConnection connection = createConnection();
                        QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
                        Queue queue = session.createTemporaryQueue();
                        QueueReceiver consumer = session.createReceiver(queue);
                        connection.start();
                       
                       
                        if (count.increment() >= NUMBER){
                            synchronized(count){
                                count.notify();
                            }
                        }
                    }
                    catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            });
            thread.start();
        }
        int maxWaitTime = 20000;
        synchronized (count) {
            long waitTime = maxWaitTime;
            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

    this.password = thePassword;
    this.clientIdGenerator = new IdGenerator();
    this.packetIdGenerator = new IdGenerator();
    this.handleIdGenerator = new IdGenerator();
    this.sessionIdGenerator = new IdGenerator();
    this.consumerNumberGenerator = new SynchronizedInt(0);
    this.sessions = new CopyOnWriteArrayList();
    this.messageDispatchers = new CopyOnWriteArrayList();
    this.connectionConsumers = new CopyOnWriteArrayList();
    this.connectionMetaData = new ActiveMQConnectionMetaData();
    this.started = new SynchronizedBoolean(false);
View Full Code Here

        this.password = thePassword;
        this.clientIdGenerator = new IdGenerator();
        this.packetIdGenerator = new IdGenerator();
        this.consumerIdGenerator = new IdGenerator();
        this.sessionIdGenerator = new IdGenerator();
        this.consumerNumberGenerator = new SynchronizedInt(0);
        this.sessions = new CopyOnWriteArrayList();
        this.messageDispatchers = new CopyOnWriteArrayList();
        this.connectionConsumers = new CopyOnWriteArrayList();
        this.connectionMetaData = new ActiveMQConnectionMetaData();
        this.closed = new SynchronizedBoolean(false);
View Full Code Here

         ServerManagement.deployQueue("testQueue");
      }

      clearMessages(false);
      hashMessages.clear();
      producedMessages = new SynchronizedInt(0);
      readMessages = new SynchronizedInt(0);
   }
View Full Code Here

/*     */
/* 118 */     this.messageRefs = new BasicPriorityLinkedList(10);
/*     */
/* 120 */     this.lock = new Object();
/*     */
/* 122 */     this.deliveringCount = new SynchronizedInt(0);
/*     */
/* 124 */     this.scheduledDeliveries = new HashSet();
/*     */
/* 126 */     this.maxSize = maxSize;
/*     */
/* 128 */     this.messagesAdded = new SynchronizedInt(0);
/*     */   }
View Full Code Here

        queueConnection.start();
    }

    public void testTemporaryQueueConsumer() throws Exception {
        final int NUMBER = 20;
        final SynchronizedInt count = new SynchronizedInt(0);
        for (int i = 0;i < NUMBER;i++) {
            Thread thread = new Thread(new Runnable() {
                public void run() {
                    try {
                        QueueConnection connection = createConnection();
                        QueueSession session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
                        Queue queue = session.createTemporaryQueue();
                        QueueReceiver consumer = session.createReceiver(queue);
                        connection.start();
                       
                       
                        if (count.increment() >= NUMBER){
                            synchronized(count){
                                count.notify();
                            }
                        }
                    }
                    catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            });
            thread.start();
        }
        int maxWaitTime = 20000;
        synchronized (count) {
            long waitTime = maxWaitTime;
            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

TOP

Related Classes of EDU.oswego.cs.dl.util.concurrent.SynchronizedInt

Copyright © 2018 www.massapicom. 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.