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
8
votes
1 answer

Can you use Future/Futuretask objects with Spring TaskExecutors?

Is it possible to use Java FutureTask with a Spring TaskExecutor to get a Future object? I'm looking for a TaskExecutor that implements the Java ExecutorService interface, in particular the submit() method. Looking through the Spring Javadocs…
James McMahon
  • 48,506
  • 64
  • 207
  • 283
8
votes
1 answer

Valid futures vs Default constructed futures

I am studying futures in my concurrent programming class. My professor has stated this in her slides: "Valid" futures are future objects associated to a  shared state, and are constructed by calling one of the following…
Flame of udun
  • 2,136
  • 7
  • 35
  • 79
8
votes
1 answer

How FutureTask is asynchronous computation

new Thread(new Runnable() { public void run() { ............. ............. ............. } }).start(); If i will do this in main it will create a new thread and will submit a task…
Trying
  • 14,004
  • 9
  • 70
  • 110
7
votes
2 answers

use FutureTask for concurrency

I have a service like: class DemoService { Result process(Input in) { filter1(in); if (filter2(in)) return... filter3(in); filter4(in); filter5(in); return ... } } Now I want it faster and I…
bylijinnan
  • 756
  • 3
  • 11
  • 27
6
votes
2 answers

Continue when one future task has expected result

I have 3 FutureTask Objects. I want that they are processed asynchronously. However, as soon as one of the FutureTasks' get() methods doesn't return null I want to continue i.e my method (wrapper) returns and doesn't wait until the other two…
Brenne
  • 265
  • 1
  • 3
  • 11
6
votes
2 answers

Difference between FutureTask and AsyncTask in android

I want to know the difference between FutureTask and AsyncTask in android. According to my thinking we can get the current situation in FutureTask. Using ExecutorService we can create a pool of parallel processes. Same property we can achieve using…
Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300
6
votes
1 answer

Seeking Clarity on Java ScheduledExecutorService and FutureTask

I'm just starting to look into Futures and the ScheduledExecutorService in Java, and I'm wondering why my Callable isn't running on the schedule I've indicated. In this sample code, the callable runs once, but the app never completes, nor does the…
marc
5
votes
4 answers

How to get to FutureTask execution state?

I have a singleThreadExecutor in order to execute the tasks I submit to it in serial order i.e. one task after another, no parallel execution. I have runnable which goes something like this MyRunnable implements Runnable { @Override public void…
Svilen
  • 1,377
  • 1
  • 16
  • 23
5
votes
1 answer

cancelling a future task in java

I want to cancel a task submitted to ExecutorService thus allowing the corresponding thread to pick a new task from the queue. Now this question have been answered many times on this forum.... like checking Thread.currentThread().interrupt() or…
gautam
  • 197
  • 1
  • 4
  • 17
5
votes
1 answer

Keep track of tasks submitted to ThreadPoolExecutor

I am running several tasks in a ThreadPoolExecutor. I initialise it as follows: private VideoExportExecutor executor; private BlockingQueue jobQueue; public void initialiseVideoProcessor() { jobQueue = new…
tishu
  • 998
  • 15
  • 29
5
votes
3 answers

Java FutureTask completion check

I have checked Oracle Java API, which gives some info that FutureTask.isDone() but I need to check whether the task has completed or terminated with any error. isDone() method will return even if it completes/terminates. But I need to know whether…
RaceBase
  • 18,428
  • 47
  • 141
  • 202
4
votes
2 answers

Convert a Stream to a Future in Flutter

a Flutter beginner here so if my question is stupid don't mind it... How can I convert a Stream to a Future? I have a Stream that just calls the requested URL multiple times because it's a Stream. I want to be able to get the data and not the…
Hussein Al-Mosawi
  • 1,464
  • 3
  • 17
  • 37
4
votes
2 answers

Android BluetoothSocket - Timing out

I have written a Bluetooth API for connecting with an external accessory. The way that the API is designed is that there are a bunch of blocking calls such as getTime, setTime, getVolume, setVolume, etc. The way these work is that they create a…
ekatz
  • 963
  • 3
  • 18
  • 38
4
votes
1 answer

Monad transformers explained in Javascript?

I'm having a hard time understanding monad transformers, partly because most examples and explanations use Haskell. Could anyone give an example of creating a transformer to merge a Future and an Either monad in Javascript and how it can be used. If…
4
votes
1 answer

java Multithreading - throttle submission to ExecutorService

I have a data file with thousand of rows. I am reading them and saving them in the database. I want to multi-thread this process in the batches of say 50 rows. As I am read in the file, 10 rows are submitted to an ExecutorService. ExecutorService…
Giovanny
  • 45
  • 1
  • 5
1
2
3
13 14