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
vote
2 answers

Best way to implement TimeoutTask

I'm trying to implement a TimeoutTask which will terminate after a given timeout. Here is what I have: import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Objects; import java.util.concurrent.Callable; import…
Tapas Bose
  • 28,796
  • 74
  • 215
  • 331
1
vote
0 answers

Pausing JavaFX task crashes App

I am a novice on JavaFX. Recently I was trying to modify the code by jewelsea found on this link : https://gist.github.com/jewelsea/4989970#file-promptingtaskdemo-java-L87 On the code above, the program pauses a FutureTask with a…
user1420482
  • 147
  • 3
  • 12
1
vote
1 answer

liftweb SetHtml couldn't handle future object in ajaxsubmit

I want to show future response in UI in a liftweb framework. Following is a Loggable snippet method(processRequest) I'm currently using to respond back future object to UI textarea using SetHtml but blocking with Thread.sleep 27 def render = { 45…
prayagupa
  • 30,204
  • 14
  • 155
  • 192
1
vote
1 answer

How to propagate timeout from one FutureTask to another dependent one used by its Callable?

I am in the following situation (perhaps I have overengineered the whole thing or I am in a complete deadlock, but cannot think to another way of doing that): Take one or more FutureTask that realize an asynchronous computation (listening of the…
Doc Davluz
  • 4,154
  • 5
  • 30
  • 32
1
vote
1 answer

ThreadPoolExecutor Future Task -exception with spring bean injection-spring-beans-2.0

I am using Weblogic 10.3, Spring 2.0,Oracle 11g. When trying to use the 'threadpoolexecutor' future task (async resp), I am getting the following exception in waiting for asynchronous response where as the bean executed by thread pool executor is…
1
vote
1 answer

Underlying thread behavior with Future.get(timeout)

We are using Future with a timeout to accomplish a task. We get a TimeOutException when time limit exceeds. From the behavior of thread dump, I realize that underlying thread continues. Is it the case? How does it take care of multiple threads…
instanceOfObject
  • 2,936
  • 5
  • 49
  • 85
1
vote
1 answer

Performing an operation days or months in the future

I'm trying to figure out the best way to perform a task, e.g. send an email to a user, in the future. My idea is to store (in a database along with users data) when the email needs to be sent, and on a daily basis check what users need emails sent,…
knownasilya
  • 5,998
  • 4
  • 36
  • 59
1
vote
1 answer

FutureTask, unsafe action

I'm getting this warning while compling my code (with -Xlint options): receptor.java:286: warning: [unchecked] unchecked call to FutureTask(java.util.concurrent.Callable) as a member of the raw type java.util.concurrent.FutureTask The line…
user1256477
  • 10,763
  • 7
  • 38
  • 62
1
vote
1 answer

How to execute operation in scala with timeout?

Context: I want to write scalding job(hadoop) to crawl pages and I want to set timeout on url extraction(without timeout on URLConnection, I want generic solution for other timeout cases) i.e. map function. I'm think about futures which are killed…
yura
  • 14,489
  • 21
  • 77
  • 126
0
votes
1 answer

Android's listView with MatrixCursor doesn't update - futureTask

I'm writing a simple xmpp client in android and I have a problem with update contactList. Im using a MatrixCursor with SimpleCursorAdapter to do it. When prog updates list it starts futureTask's thread. Data is ok, but list on screen doesn't refresh…
0
votes
0 answers

Python asynchronous POST calls with AIOHTTP -- RuntimeError: await wasn't used with future

I've scoured StackOverflow for similar questions and haven't found an answer that fits my need. I'm trying to use MalwareBaazar's API to get info about a number of file hashes via POST requests (via API spec). The API has no rate limiting nor a…
cmt_
  • 13
  • 7
0
votes
0 answers

How to mock callable futureTask.get(long, TimeUnit) method to return a response

I have a callable FutureTask that is getting executed using ExecutorService. FutureTask> attestationDbTask = new FutureTask>(() ->…
0
votes
1 answer

FutureBuilder runs twice even it is not supposed to

This is my code: class HomePage extends StatefulWidget { const HomePage({Key? key}) : super(key: key); @override State createState() => _HomePageState(); } class _HomePageState extends State { late…
0
votes
1 answer

How to send data from one future task to another future task in flutter?

For example there are 4 Future tasks in flutter that are dependent on each other and after these tasks are completed Navigator.pushReplacement is called to change function. By dependent it means that return value of one Future is the argument of…
0
votes
0 answers

Flutter-Web : Future doesn't change the variable

I've this code in a Flutter page. This code is supposed to show to the user that his orders had been send to the database. I use a future with the function .then and I should get the response status code 200 which is printed in the debug console of…