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

Return a value inside a CompletableFuture in another CompletableFuture and return that future

I want to get a value inside a CompletableFuture (in this case clonedWorld) in another CompletableFuture and return that future. This is my code, and I'm stuck here: @Override public CompletableFuture asyncCloneWorld(String worldName,…
thatflow
  • 25
  • 6
0
votes
0 answers

JNA callback method wont be called until futureTask.get() timeout

If I run like this, the callback block will not run so future.get() will block forever: FutureTask futureTask = new FutureTask<>(System::currentTimeMillis); boolean login = CameraSDk.login(ip, port, userName, password, (lLoginID,…
King K
  • 1
0
votes
1 answer

Android: Wait for userinput but set a timeout

In my application the user is prompted with an exercise and he has 5 seconds to solve it, if he does not respond in time, the next exercise should be shown. My question is: What would be the best way to implement such a behaviour in Android? I have…
0
votes
1 answer

FutureTask get() method may distable LockSupport.park

i found FutureTask get() method may distable LockSupport.park in oracle jdk8 my code is : ExecutorService service = Executors.newFixedThreadPool(1, (r) -> { Thread thread = new Thread(r); thread.setDaemon(true); …
0
votes
2 answers

Future Task Async Calls hanging while exception occurs

I wrote many Async Future Task Calls one below another in my java program. Giving one sample below FutureTask> x = getConditionFacts(final Member member); FutureTask> x = getRiskFacts(final Member…
juniorbansal
  • 1,249
  • 8
  • 31
  • 51
0
votes
1 answer

Constructing a DAG of cancelable Java tasks

I want to create a DAG out of tasks in Java, where the tasks may depend upon the output of other tasks. If there is no directed path between two tasks, they may run in parallel. Tasks may be canceled. If any task throws an exception, all tasks are…
Luke Hutchison
  • 8,186
  • 2
  • 45
  • 40
0
votes
2 answers

Why this future function is returning empty list flutter

I am new with flutter having issues with the future functions. I had a single await function on other screen and its returning list but when I use multiple await function in a single future function it returns an empty list and executes before many…
0
votes
2 answers

Flutter - Pull to refresh with RefreshIndicator in FutureBuilder

Edit: Minimal reproducible example. Please have a look at the refresh-Method in main.dart. I'm using a FutureBuilder to display the result of a network request. I call my fetch method in initstate (like suggested here): Future>…
Matthias
  • 3,729
  • 22
  • 37
0
votes
0 answers

Better method to replace AsyncTask being deprecated to get data from server

I see there are several options to replace AsyncTask now being deprecated. I get a little unsure or confuse or both which option is best to use. Actually my asynctask get data form a server, which can take up to 2-5 seconds. I see these…
0
votes
1 answer

What is a Best way to handle Multi threading with callbacks in Kotlin?

I want to display multiple windows in a queue after some wait time. So what is the best way to implement the same? ThreadPoolExecutor FutureTask Coroutines or any other way in Kotlin?
Appcapster
  • 139
  • 1
  • 9
0
votes
1 answer

Mockito Mock method parameter of type Future

I have the below code: public final class JoinableTaskPool extends ABC { public Future submit(final Callable task) { executorService.submit(new Runnable() { public void run() { try { …
BigDataLearner
  • 1,388
  • 4
  • 19
  • 40
0
votes
1 answer

Trying to make sequential executing of futures. What is wrong?

I am trying to execute function which returns Future sequentially So, I have a collection val in = Seq(1, 1, -1, -2, 3, -4, 5, 6, 7, -1, -2, -9, 1, 2, 2) and function to process every int in this collection def intToFuture(int: Int):…
0
votes
0 answers

Why does only some of my objects get created using std::async

I have a loop that pushes back calls of std::async that are used to create objects in the pointed function and emplace them back to another vector. All the calls are pushed to the futures function and the results are ready when i used the VS…
Chill Kid
  • 11
  • 4
0
votes
0 answers

How to completely stop / terminate a task that has already been submitted to an ExecutorService in Java?

Problem : I have an use case where I want to cancel a task that has already been submitted to an executor service. future.cancel() is not helpful to me as the task does not go to wait() / sleep() state during the execution. Also, adding…
0
votes
2 answers

Exception type Future(void) in not subtype of Future

the code below performs the creation of a layout in flutter, to create the layout I must first make sure that the set function is executed to make it use future builder but when I run the code I have the following error. It tells me that the…
riki
  • 1,502
  • 5
  • 17
  • 45