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

Identifying the AWT thread

I have a class, which decorates JTextComponent from Swing. Methods that it contains can be called from any thread, so I have to ensure, that code which works with JTextComponent will be performed by AWT thread. The second requirement is, that…
0
votes
2 answers

Android: FutureTask cannot be cast to MyClass

Situation : A function calls a thread to send data to the server. This thread in turn spawns yet another thread, to obtain results from the server using ObjectInputStream(). Finally, this object is returned to the calling function by the spawned…
Abhishek
  • 743
  • 1
  • 15
  • 28
0
votes
1 answer

Submitting Callable to ExecutorService is never completed

The problem which i am facing has been nagging for a week now and here it is: I have a class AdminBlocageBackgroundProcessing.java which processes a CSV file by reading data from it and validating it and storing it in a array list as: public Object…
0
votes
1 answer

how can i update the value of a global variable in FutureTask's call method

i'm trying to figure out how concurrency works in javafx by reading the article javafx concurrency,however, i wonder how can i update the value of a global static variable in call method of FutureTask object ? Here is a simple example to understand…
quartaela
  • 2,579
  • 16
  • 63
  • 99
0
votes
1 answer

Thread safety issue while timing out the thread for each bundle

I am working on a project in which I will have different Bundles/Models. Let's take an example, Suppose I have 4 bundles and each of those bundles will have a method name process. Below are the things, I am supposed to do- I need to call all those…
arsenal
  • 23,366
  • 85
  • 225
  • 331
0
votes
1 answer

FutureTask with Callable that references the FutureTask

I have a situation where I need to create a FutureTask with a Callable that checks if it's owner has been cancelled. The code I have looks like this: public static FutureTask makeFuture(final Call call, final TaskCompletionCallback…
aliak
  • 428
  • 4
  • 12
0
votes
2 answers

Multithreading - Naming threads and handling exceptions

In java, what are the suggested ways to implement the two thread requirements I would like the name a thread I would like the parent (or main) thread know if there are any exceptions by this child thread. For 2, I understand that having a future…
Andy Dufresne
  • 6,022
  • 7
  • 63
  • 113
0
votes
1 answer

Interrupt and restart tasks when using ScheduledThreadPoolExecutor

I'm having a little problem understanding how ScheduledThreadPoolExecutor works (I'm using SCA so don't bother with the annotations inside the code). That's part of the code from my Scheduler class: @AllowsPassByReference public ScheduledFuture
0
votes
1 answer

Trouble using FutureTask for Asynchronous proceedures

In my Java web app I have a method which ends out about 200 emails. Because of email server delay the whole process takes about 7 minutes. This bulk email sending has to take place as the result of user action. I of course don't want the user to…
sgd
  • 31
  • 4
0
votes
2 answers

How to properly extend FutureTask

While coding a computation-heavy application, I tried to make use of the SwingWorker class to spread the load to multiple CPU cores. However, behaviour of this class proved to be somewhat strange: only one core seemed to be utilized. When searching…
nvx
  • 3
  • 1
  • 3
0
votes
1 answer

How can I call another method after all `FutureTask` have finished their computations?

I have the following method that creates and deploys applications in different PaaS: private void deployModulesInPaaS() { ExecutorService executor = Executors.newFixedThreadPool(listModules .size()); ModuleParsed…
eskalera
  • 1,072
  • 2
  • 21
  • 36
0
votes
1 answer

Java HTTPServlet vs Standalone App + some OutOfMemory Fun

I have a function that loads several serialized objects from the file system by using Java 5 FutureTask. My computer memory should not be an issue. If I call the function within a main method everything works fine but if I call the function from…
Marsellus Wallace
  • 17,991
  • 25
  • 90
  • 154
0
votes
1 answer

Synchronizing issue: I want the main thread to be run before another thread but it sometimes doesn´t

I have done my own small concurrency framework (just for learning purposes) inspired by the java.util.concurrency package. This is about the Callable/Future mechanism. My code below is the whole one and is compilable and very easy to understand. My…
Rox
  • 2,647
  • 15
  • 50
  • 85
0
votes
2 answers

read 2 file in same time, no more performance

I tried to read to file in same time and return the number of line ExecutorService executor = Executors.newFixedThreadPool(2); FutureTask futureOne = new FutureTask(new Calcul1()); FutureTask futureTwo = new…
robert trudel
  • 5,283
  • 17
  • 72
  • 124
0
votes
2 answers

Implementing asynchronous call using FutureTask and callback

So right now, I am trying to implement an asynchronous call which calls my BasicHttpClient to get Http response from the internet, when the Http client done its work, it calls one of Callee class's methods. Generally, my implementation looks like…
kevin
  • 807
  • 3
  • 11
  • 20
1 2 3
13
14