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

ScheduledFuture returns null when a task is submitted or scheduleAtFixedRate

I am trying to schedule a job to run every 10 minutes using ScheduledThreadPoolExecutor. There are 10 threads in the thread pool. Code looks like: ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(10, r -> { …
Sart
  • 9
  • 1
-1
votes
2 answers

Java's CompletableFuture : time of ExecutionException

When working with CompletableFuture any potential errors from computing the value are exposed via the get() method throwing an ExecutionException. I can of course log this exception at the time of calling this method, but it would be misleading as…
peterh
  • 18,404
  • 12
  • 87
  • 115
-1
votes
1 answer

Why even after putting await keyword my app will show 0?

I have called trigger function inside initState function.In trigger function i will be taking data from an API and i parsed the data using storeddata.fromjson function. Then afterwards i will store those values in variables. As far as i know…
Varun Hegde
  • 115
  • 1
  • 6
-1
votes
1 answer

Computation with Futures avoiding Await method

I have funtion which is calling computeParallel() function which is calling 3 Futures F1,F2,F3 and returning String as return type. def computeParallel():String = { val f1 = Future { "ss" } val f2 = Future { "sss" } val f3 =…
-1
votes
1 answer

Spring re-try withing future tasks not working

I have a spring-boot application which which needs to call external APIs. If there are 'n' external calls, 'n' future tasks will be created and rest calls will be made. Problem here is if any of the rest call fails with exception, i need to retry…
-1
votes
1 answer

Modify collection with ResultSetFuture

I tried implementing async query using java-driver-async-queries. I am modifying a List within the FutureCallback but seems its not working - List products = new ArrayList(); for (// iterating over a Map) { key =…
Saurabh
  • 2,384
  • 6
  • 37
  • 52
-1
votes
3 answers

Fatal Exception AsyncTask #1 at doInBackground()

I am newbie on Android and I am developing an app that gets some information from a QR code and then connects a php page. However app crushes after it reads QR code and logCat gives a Fatal Exception AsyncTask #1 when I run it. Here is the…
ciyo
  • 725
  • 4
  • 16
  • 36
-1
votes
3 answers

FutureTask and Callable usage

i have a functionality to implement for which I am thinking about using FutureTask and callable calsses.just want to verify if I can use this and if it is correct to use these classes in such situations. Here it is : I am working on a web…
Shailesh Vaishampayan
  • 1,766
  • 5
  • 24
  • 52
-2
votes
1 answer

Async API using Future never completes

I try to make an API aysnchronous as: Future fASync(int x) { return new FutureTask(() -> { try { Thread.sleep(new Random().nextInt(1, 3) * 1000); } catch (InterruptedException e) { …
Mandroid
  • 6,200
  • 12
  • 64
  • 134
-2
votes
1 answer

Gson deserialization throws FutureTask error

CASE SOLVED UPDATE: The thing was that GSON have problems trying to deserialize into an Long object while it is into a running Thread, all I had to do was to deserialize manually my String by adding the part of the String with the long number into…
-2
votes
1 answer

Java Future: Issue while trying to understand .get() method

import java.io.*; import java.util.concurrent.*; import java.util.concurrent.TimeUnit; import java.util.concurrent.Callable; class _TimeOut_ extends PrintIn_Delays { public static void main(String[] args) throws InterruptedException { …
-2
votes
2 answers

How to use FutureTask, waiting for ui event?

I have an interface method which is supposed to return a Future object. Future doSomething() The implementation of this method shows some ui (javafx). One of the ui elements has a listener, that needs to be called in order to receive the…
andre
  • 1,618
  • 2
  • 19
  • 38
-3
votes
1 answer

Java: Adding Future to a list

Now that I have a handle on retrieving objects in parallel, how can I add those objects to a list? I have a list of Future objects that I'm attempting to add to an ArrayList of Site objects. Here's my for loop. I can add a print statement in…
TheFunk
  • 981
  • 11
  • 39
1 2 3
13
14