Package java.util.concurrent

Examples of java.util.concurrent.FutureTask$Sync


   * @param runnable
   *            The Runnable that has to be called on JFX thread.
   */
  static public void runAndWait(final Runnable runnable) {
    try {
      FutureTask future = new FutureTask(runnable, null);
      Platform.runLater(future);
      future.get();
    }
    catch (InterruptedException | ExecutionException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here


            _oneInstance),

            _timeout);

         _futureResult = new FutureTask(_callable);
         return _futureResult;
        
      }
      catch (Exception e)
      {
View Full Code Here

   }

   public Object call() throws Exception
   {

      FutureTask result = new FutureTask(function);


      Thread thread = Executors.defaultThreadFactory().newThread(result);

      thread.start();

      try
      {

         startingTime = System.currentTimeMillis();

         Object obj = result.get(millis, TimeUnit.MILLISECONDS);

         endingTime = System.currentTimeMillis();

         return obj;
View Full Code Here

     */

    @SuppressWarnings("unchecked")
    public CallbackFuture(InvocationContext ic, AsyncHandler handler) {
        cft = new CallbackFutureTask(ic.getAsyncResponseListener(), handler);
        task = new FutureTask(cft);
        executor = ic.getExecutor();
       
        /*
         * TODO review.  We need to save the invocation context so we can set it on the
         * response (or fault) context so the FutureCallback has access to the handler list.
View Full Code Here

        synchronized (tasks)
        {
            Iterator<FutureTask> taskIterator = tasks.iterator();
            while (taskIterator.hasNext())
            {
                FutureTask task = taskIterator.next();
                task.cancel(true);
            }
            tasks.clear();
        }
    }
View Full Code Here

     * @throws QueryInterruptedException if the operation is cancelled (by the user in another thread)
     */
    protected Object performExecuteTask(final Object... args)
    {
        Integer timeout = getTimeoutMillis();
        FutureTask theTask = null;
        final Object[] threadResults = new Object[1];
        try
        {
            // Execute the query in its own thread so we can time it out
            theTask = new FutureTask(new Runnable()
            {
                public void run()
                {
                    threadResults[0] = performExecuteInternal(args);
                }
            }, null);
            tasks.add(theTask);

            // start task in a new thread
            if (NucleusLogger.QUERY.isDebugEnabled())
            {
                if (timeout != null && timeout > 0)
                {
                    NucleusLogger.QUERY.debug(LOCALISER.msg("021019", toString(), timeout));
                }
                else
                {
                    NucleusLogger.QUERY.debug(LOCALISER.msg("021022", toString()));
                }
            }
            new Thread(theTask).start();

            // wait for the execution to finish, timeout after the users limit is exceeded if required
            if (timeout != null && timeout > 0)
            {
                theTask.get(timeout, TimeUnit.MILLISECONDS);
            }
            else
            {
                theTask.get();
            }
            tasks.remove(theTask);
        }
        catch (TimeoutException e)
        {
View Full Code Here

     * @param results The results
     * @return The query task
     */
    protected FutureTask getPerformExecuteTask(final Map parameters, final Object[] results)
    {
        FutureTask theTask = new FutureTask(new Runnable()
        {
            public void run()
            {
                results[0] = performExecute(parameters);
            }
View Full Code Here

      return recvBuf;
    }

    ExecutorService executor = Executors.newSingleThreadExecutor();
    MultiFetch multiFetch = new MultiFetch();
    FutureTask<?> task = new FutureTask(multiFetch, null);
    executor.execute(task);
    try {
      task.get(fetchTimeoutSeconds, TimeUnit.SECONDS);
    } catch(InterruptedException ie) {
      // attempt to cancel execution of the task.
      task.cancel(true);
      LOG.error("interrupted during fetch: "+ie.toString());
    } catch(ExecutionException ee) {
      // attempt to cancel execution of the task.
      task.cancel(true);
      LOG.error("exception during fetch: "+ee.toString());
    } catch(TimeoutException te) {
      // attempt to cancel execution of the task. 
      task.cancel(true);
      LOG.error("timeout for fetch: "+te.toString());
    }

    executor.shutdownNow();
    multiFetch.close();
View Full Code Here

TOP

Related Classes of java.util.concurrent.FutureTask$Sync

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.