Questions tagged [futuretask]

A cancellable asynchronous computation. This class provides a base implementation of Future, with methods to start and cancel a computation, query to see if the computation is complete, and retrieve the result of the computation.

A cancelable asynchronous computation. This class provides a base implementation of Future, with methods to start and cancel a computation, query to see if the computation is complete, and retrieve the result of the computation. The result can only be retrieved when the computation has completed; the get method will block if the computation has not yet completed. Once the computation has completed, the computation cannot be restarted or cancelled.

A FutureTask can be used to wrap a Callable or Runnable object. Because FutureTask implements Runnable, a FutureTask can be submitted to an Executor for execution.

In addition to serving as a standalone class, this class provides protected functionality that may be useful when creating customized task classes. source.

208 questions
0
votes
1 answer

When using an ExecutorService, is it possible for a Thread to become uninterruptible when in the WAITING state

I'm running into an issue where it seems as if a Thread has become uninterruptible while in a WAITING state. The task thread itself (as you'll see in the stack of the thread below) is waiting for a call to FuturePromise.get() (a Jetty class). The…
Mike
  • 33
  • 3
0
votes
2 answers

Future and asynchronism

I use a extern api (ESRI API for Android) where I have a loop for which me return a class Future ... for (Layer layer : layers) { // ListenableFuture extends Future final ListenableFuture future=…
lg0173
  • 208
  • 2
  • 8
  • 20
0
votes
2 answers

for a list how to create future task one at a time

I have given list in java List list; And I have a function which takes String and gives CompletionStage. I want to iterate through list and process each task sequentially, That is when one task gives result then only i want to schedule next…
hridayesh
  • 1,123
  • 1
  • 14
  • 36
0
votes
1 answer

Cancelling a Callable implementation doesn't work correctly

I began to immigrate to java thread pool instead of own my framework for pooling threads. So, I wrote a sample for this aim. Actually, the largest requirement is to stop the running thread if its execution is too late. In addition, to achieve this…
Sam
  • 6,770
  • 7
  • 50
  • 91
0
votes
1 answer

Execute a same method in parallel with different input's using Future and @ Async

I have a java method that needs to be execute in parallel with different set of input's(from list). Basically my business logic method has some external call logic that consumes little amount of time to respond. In order to reduce my overall time to…
Mohan
  • 3,893
  • 9
  • 33
  • 42
0
votes
0 answers

Motivation of implementation awaitDone method of FutureTask class

I'm currently trying to understand the internals of java.util.concurrent.FutureTask implementation. I understand the purpose of the class, but the implementation looks complicated for me. Could someone provide intention comments for the awaitDone…
0
votes
4 answers

Java Waiting for all threads to complete

Edit: My question is different, it has no relevance to the linked question. I've following code with completion handler. FutureTask futureTask = new FutureTask(() -> { System.out.println("callback"); return null; }); Runnable…
user2727195
  • 7,122
  • 17
  • 70
  • 118
0
votes
1 answer

Avoid JNI ERROR generated by Java code in Android

I'm developing a test for some hundreds of regex I have to manage in Android. I encountered a catastrophic backtracking I cannot prevent, (i.e., the matcher enters an exponential complexity and it seems it is in an infinite loop, while, in reality,…
0
votes
1 answer

Sharing Object across threads in java which calls AsynFuture

I have created a runnable class A which executes some task for me. I am submitting this class using ExecutorService so that I can execute these tasks in parallel. The runnable class A calls another object B which sends an AsyncFuture request…
user2780757
  • 191
  • 1
  • 11
0
votes
1 answer

Akka-Java: Unable to receive Future message in parent using pipe pattern

I am creating one child actor for one parent. My child actor perform some business logic and return value to scala Future. When i send Future message to my parent, i am unable to catch my future message. Following is my code: Child Actor public…
Harmeet Singh Taara
  • 6,483
  • 20
  • 73
  • 126
0
votes
4 answers

Implement a cancelable thread manager for a unique object

I need to manage many background threads that do something with some objects as key but only one thread can work with same object at the same time, For example while thread A is working on object A, if thread B called for working with object A,…
Farshad
  • 3,074
  • 2
  • 30
  • 44
0
votes
1 answer

Can Java's FutureTask be an alternative to AsyncTask?

The docs say AsyncTask is designed to handle short operations(few seconds maximum) and states that Java classes like FutureTask are better for operations that last long. So I tried to send my location updates to the server using FutureTask but I am…
The_Martian
  • 3,684
  • 5
  • 33
  • 61
0
votes
1 answer

How to remove java.util.concurrent.RejectedExecutionException while using Future Interface

I have a controller in which I am using future interface and creating 5 threads in threadpool. This controller is called by an ajax call. When I call this controller the first time it runs fine but if I make the request again it shows the exception…
Jaydeep
  • 149
  • 2
  • 5
  • 19
0
votes
0 answers

Tasks are getting failed

Task failed at: 2016-04-10T13:03:44.152+07:00 com.subex.spark.taskcontroller.tasks.TaskComponentException: at…
0
votes
1 answer

Cleanup FutureTask after using

I wonder if after the FutureTask finishes his job and I can get the result from it successfully, should I cleanup the FutureTask to release the resource ? Or the FutureTask will be cleaned up automatically after a certain amount of time after it…
Xitrum
  • 7,765
  • 26
  • 90
  • 126