Package java.util.concurrent

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


                                    if(!acquired) {
                                        try {
                                            if (stackLogger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
                                                stackLogger.logDebug("trying to acquiring semaphore for message " + message);
                                            }
                                            callIdSemaphore.acquire();
                                        } catch (InterruptedException e) {
                                            stackLogger.logError("Semaphore acquisition for message " + message + " interrupted", e);
                                        }
                                        if (stackLogger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) {
                                            stackLogger.logDebug("semaphore acquired for message " + message);
View Full Code Here


        //List<MergeApplication> channels = new ArrayList<MergeApplication>();
        MergeApplication[] channels = new MergeApplication[count];
        try{
            // Create a semaphore and take all its permits
            Semaphore semaphore = new Semaphore(count);
            semaphore.acquire(count);

            // Create activation threads that will block on the semaphore
            for(int i = 0;i < count;i++){              
                channels[i] = new MergeApplication(names[i],semaphore,false);                   
                // Release one ticket at a time to allow the thread to start
View Full Code Here

        // Create a semaphore and take all its tickets
        Semaphore semaphore = new Semaphore(count);

        try{

            semaphore.acquire(count);
            // Create activation threads that will block on the semaphore
            for(int i = 0;i < count;i++){
                if(largeState){
                    channels[i] = new ConcurrentLargeStateTransfer(names[i],
                                                                   semaphore,
View Full Code Here

  {
    Semaphore sem = semaphore;
   
    if (sem != null)
    {
      sem.acquire();
    }
  }
 
  public boolean tryAcquire(long timeout) throws InterruptedException
  {
View Full Code Here

    public void testStateTransferWhileSending() throws Exception {
        StateTransferApplication[] apps = new StateTransferApplication[APP_COUNT];

        // Create a semaphore and take all its permits
        Semaphore semaphore = new Semaphore(APP_COUNT);
        semaphore.acquire(APP_COUNT);

        int from = 0, to = MSG_SEND_COUNT;
        String[] names = createApplicationNames(APP_COUNT);

        for(int i = 0;i < apps.length;i++){
View Full Code Here

        // Create a semaphore and take all its tickets
        Semaphore semaphore = new Semaphore(channelCount);

        try{

            semaphore.acquire(channelCount);
            boolean crashed = false;
            // Create activation threads that will block on the semaphore
            for(int i = 0;i < channelCount;i++){
                StreamingStateTransferApplication channel = null;
               
View Full Code Here

        ConcurrentStartupChannel[] channels = new ConcurrentStartupChannel[count];
        try{
            // Create a semaphore and take all its permits
            Semaphore semaphore = new Semaphore(count);
            semaphore.acquire(count);

            // Create activation threads that will block on the semaphore
            for(int i=0;i < count;i++) {

                channels[i]=new ConcurrentStartupChannel(names[i], semaphore, useDispatcher,connectAndGetState);
View Full Code Here

        ArrayList<FlushTestReceiver> channels = new ArrayList<FlushTestReceiver>(count);
        try{
            // Create a semaphore and take all its permits
            Semaphore semaphore = new Semaphore(count);
            semaphore.acquire(count);

            // Create channels and their threads that will block on the
            // semaphore
            for(int i = 0;i < count;i++){
                FlushTestReceiver channel = new FlushTestReceiver(names[i], semaphore, 0, connectType);               
View Full Code Here

        ShunChannel[] channels = new ShunChannel[count];
        try{
            // Create a semaphore and take all its permits
            Semaphore semaphore = new Semaphore(count);
            semaphore.acquire(count);

            // Create activation threads that will block on the semaphore
            for(int i = 0;i < count;i++){              
               channels[i] = new ShunChannel(names[i],
                                             semaphore,
View Full Code Here

                        new Callable<Object>()
                        {
                            @Override
                            public Object call() throws Exception
                            {
                                semaphore.acquire();
                                mutex.acquire();
                                Assert.assertTrue(hasLock.compareAndSet(false, true));
                                try
                                {
                                    if ( isFirst.compareAndSet(true, false) )
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.