Package java.util.concurrent

Examples of java.util.concurrent.ExecutorService.invokeAny()


      Assert.assertNotNull(connection);
      pool.release(connection);
      connection = pool.acquire(host);
      Assert.assertNotNull(connection);
      ExecutorService service = Executors.newSingleThreadExecutor();
      service.invokeAny(Collections.singleton(new Callable<Connection>() {
        @Override
        public Connection call() throws Exception {
          return pool.acquire(host);
        }
      }), 2, TimeUnit.SECONDS);
View Full Code Here


      Assert.assertNotNull(connection);
      pool.release(connection);
      connection = pool.acquire(host);
      Assert.assertNotNull(connection);
      ExecutorService service = Executors.newSingleThreadExecutor();
      service.invokeAny(Collections.singleton(new Callable<Connection>() {
        @Override
        public Connection call() throws Exception {
          return pool.acquire(host);
        }
      }), 2, TimeUnit.SECONDS);
View Full Code Here

            ExecutionException, TimeoutException {
        ExecutorService service = delegate.get();
        if (service != null) {
            // since the tasks are either executed or cancelled, there is no
            // need to track them
            return service.invokeAny(tasks, timeout, unit);
        }
        throw new RejectedExecutionException(
                "Execution service is terminated. No more tasks can be executed.");
    }
View Full Code Here

            throws InterruptedException, ExecutionException {
        ExecutorService service = delegate.get();
        if (service != null) {
            // since the tasks are either executed or cancelled, there is no
            // need to track them
            return service.invokeAny(tasks);
        }
        throw new RejectedExecutionException(
                "Execution service is terminated. No more tasks can be executed.");
    }
View Full Code Here

         });
      }
      try
      {
         // we wait 5 seconds to get the first matching hardware address. After that, we give up and return null
         byte[] address = executor.invokeAny(tasks, 5, TimeUnit.SECONDS);
         return address;
      }
      catch (Exception e)
      {
         return null;
View Full Code Here

         });
      }
      try
      {
         // we wait 5 seconds to get the first matching hardware address. After that, we give up and return null
         byte[] address = executor.invokeAny(tasks, 5, TimeUnit.SECONDS);
         return address;
      }
      catch (Exception e)
      {
         return null;
View Full Code Here

      ExecutionException, TimeoutException {
    ExecutorService service = delegate.get();
    if (service != null) {
      // since the tasks are either executed or cancelled, there is no
      // need to track them
      return service.invokeAny(tasks, timeout, unit);
    }
    throw new RejectedExecutionException(
        "Execution service is terminated. No more tasks can be executed.");
  }
View Full Code Here

      throws InterruptedException, ExecutionException {
    ExecutorService service = delegate.get();
    if (service != null) {
      // since the tasks are either executed or cancelled, there is no
      // need to track them
      return service.invokeAny(tasks);
    }
    throw new RejectedExecutionException(
        "Execution service is terminated. No more tasks can be executed.");
  }
View Full Code Here

    String result;
    try {
      // Send the list of tasks to the executor and waits for the result of the first task
      // that finish without throw and Exception. If all the tasks throw and Exception, the
      // method throws and ExecutionException.
      result = executor.invokeAny(taskList);
      System.out.printf("Main: Result: %s\n",result);
    } catch (InterruptedException e) {
      e.printStackTrace();
    } catch (ExecutionException e) {
      e.printStackTrace();
View Full Code Here

         });
      }
      try
      {
         // we wait 5 seconds to get the first matching hardware address. After that, we give up and return null
         byte[] address = executor.invokeAny(tasks, 5, TimeUnit.SECONDS);
         return address;
      }
      catch (Exception e)
      {
         return null;
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.