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

Is there a way I can use Future values in Dart to fill Textfields?

I've been learning Dart with flutter and was creating Weather App for practices , I managed to successfully create the UI , I used Dark Sky weather API since it has 7 day weather forecast but instead of taking the long road of decoding json and…
Yasir MK
  • 3
  • 2
0
votes
1 answer

What is the difference between the two uses of FutureTask?

use thread pool: ExecutorService exec = Executors.newFixedThreadPool(5); FutureTask ft = new FutureTask(() -> rpcMethod()); exec.submit(ft); call run method: FutureTask ft = new FutureTask(() ->…
zzkyeee
  • 65
  • 6
0
votes
2 answers

Parallel Computation with Scala Futures

I have a Function that computes two sub-functions like this. def someFutureMethod1(input: Int): Int = { input + 1 } def someFutureMethod2(input: Int): Int = { input + 12 } def method1(sx: Int): Future[Int] = Future { val…
0
votes
1 answer

Get values for variables in FutureBuilder and use in layout

Variable dependent widgets are processed before FutureBuilder finishes execution. With the following code 'subtraction was called on null' error appears. - Is it possible to get word (problem) variable before creating rest widgets in layout with it?…
mktplus
  • 504
  • 1
  • 4
  • 17
0
votes
1 answer

how to execute code after the exception in scala using Try

i have two actors they can either return the Result which is a boolean value in my case or they can throw an exception here is my code val futureA: Future[Boolean] = ask(ActorA, MessageA(obj)).mapTo[Boolean] val resultA = Await.result(futureA,…
swaheed
  • 3,671
  • 10
  • 42
  • 103
0
votes
0 answers

How can I make JNDI Registry thread safe?

I have a class which creates the camel routes dynamically. Previously it creates routes through a simple loop, But now I want to make sure all routes are start at the same time. For that I used FutureTask. Now I got the…
MKRISH
  • 21
  • 5
0
votes
1 answer

How is the runner used to run the Callable in FutureTask

In the source code of FutureTask, there is a volatile instance variable Thread runner, where the comment told that it is the thread running the callable. However, the runner is never initialized in the source code. Moreover, I could not find any…
Rui
  • 3,454
  • 6
  • 37
  • 70
0
votes
3 answers

How to restrict the number of threads using a Java service

My requirement is to restrict the number of threads which uses my service at any point in time. Executor service is not helping me here as my problem space is little different. Let me explain with an example. I have exposed a REST API which does one…
goosebump
  • 96
  • 1
  • 2
  • 13
0
votes
2 answers

Android ANR , Service is locking main GUI Activity

Im starting several background services that take a while to configure due to web services calls, etc... However Im starting these services via AsyncTask in order to avoid locking the main thread & GUI, however the GUI stills becomes locked. Im…
cyber101
  • 2,822
  • 14
  • 50
  • 93
0
votes
0 answers

Java Future - postpone a task

I have the following 2 init methods that call doDataInit(): public void sessionBegin(SessionEvent event) throws Exception { .... doDataInit(); } public void init() { ... doDataInit(); } and the…
Joe Fisher
  • 97
  • 1
  • 1
  • 6
0
votes
1 answer

flutter catching errors of nested async methods

I have this method. asyncFunction1() async { Firestore.instance.runTransaction((transaction){ var first = await transaction.something; var second = await secondInside(); }); } Now I want to call this method, and catch every error that…
Tree
  • 29,135
  • 24
  • 78
  • 98
0
votes
0 answers

I need a return getting a value from inside the callback method

I need to return a ListView from the following code. getUser() is a function to return a user from the database, that does it asynchronously. I'm using Firebase, by the way. I need it to return the ListView after the Callback from retrieving data…
0
votes
0 answers

How to terminate a task and continue the next one after a specified time limit?

My "queryService.query()" make take a time that exceeds a limit specified by the requirement. I want to be able to skip the execution of the current function all after 1 second and then continue to process of the next "inputInfo". If a task takes…
user697911
  • 10,043
  • 25
  • 95
  • 169
0
votes
0 answers

How to handle multiple return types using Future and executer's invokeAll in Java8?

How to handle multiple return types in future.get when invokeall is called? List>> futureListe = executor.invokeAll(Classableobjekts); //Objekts list contain two objects of different types say Class1 and CLass2. …
fatherazrael
  • 5,511
  • 16
  • 71
  • 155
0
votes
0 answers

Future Task on Web - returns the old result in the new execution

I created a WebService that runs a algorithm that takes 15 minutes running. The algorithm returns a result (JSON). Because of the result, I am using a thread "Future Task". After I deploy the application, when I run, it returns me the correct…
user17245
  • 207
  • 1
  • 8