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

OrientDB - Java process: memory out of control

I've written a paralellized alghoritm to accomplish a calculation on data stored in a Orient table. To take under control memory, I try to paginate these data and I try to parallelize my alghoritm about increase performance (using Future task). My…
Joe Taras
  • 15,166
  • 7
  • 42
  • 55
0
votes
3 answers

Get result from call that doesn't return result?

I'm using an API that makes calls for results, but doesn't return the result itself. Once the call is made, a separate method (a listener) is invoked, which contains the result. Here's an example of what I'm trying to achieve: public static void…
Anonomoose
  • 137
  • 1
  • 1
  • 8
0
votes
0 answers

JavaFX: Platform.runLater(task) not recognized for task = new FutureTask<>(new Runnable() {....}?

Over the last two weeks I have studied 10 different ways to avoid problems with sleep(). The concept of running a block of code on the UI Thread that cannot be interrupted seems the most practical. So I have proceeded to create a FutureTask
sgroen
  • 29
  • 1
  • 8
0
votes
0 answers

How to make a Future Task Threads Atomic(Transactional) in Java Spring

I m trying to make each thread atomic. I already tried using proxy annotations to begin and end transaction after the execute method but it didn't work and also I tried using transaction annotation on the class level and method level both didn't…
user1364861
  • 301
  • 1
  • 2
  • 16
0
votes
1 answer

Why can we assign FutureTask object to Future variable?

Here is the snippet from the book Java Concurrency in Practice that confused me: interface Computable { V compute(A arg) throws InterruptedException; } public class Memoizer3 implements Computable { private final…
user2916610
  • 765
  • 1
  • 5
  • 12
0
votes
1 answer

Android calling AsyncTask().get() without execute()?

I'm having issues trying to understand how AsyncTask().get() actually works. I know it's a synchronous execution, However: I don't know how execute() and get() are connected. I have this sample code from Google's docs: // Async Task Class class…
nightfixed
  • 871
  • 1
  • 12
  • 24
0
votes
1 answer

Android: Future/FutureTask for parallel processing of data

I am trying to optimize a complex data updater and parser for my Android app. The server provides three interface functions. The parser requires the data from all those three functions. When the download of the data is finished, the parser can…
Denis Loh
  • 2,194
  • 2
  • 24
  • 38
0
votes
1 answer

Java Executor to execute one Callable after previous has finished?

I have a custom business requirement. I need to execute a series of service calls. Each of these call creates a new record in the database. I need to execute the next service call only after the previous service call has finished, because the new…
SPS
  • 183
  • 1
  • 2
  • 10
0
votes
2 answers

ArrayAdapter refreshing data

I am building an application which is dynamically populating/depopulating arraylist depending on Futuretask thread which communicates with server. Problem is that when i add new object into my arrayadapter and in any way i call notifyDataSetChanged…
Smarty77
  • 1,208
  • 3
  • 15
  • 30
0
votes
1 answer

Is there any way to wait a status using Callable in java?

I have a problem: I create a Task that implements Callable. This task has a mission that wait for the status return to false. The status is depending on the server return. I dont know exactly when server return to false. So I create a task with name…
cauchuyennhocuatoi
  • 461
  • 3
  • 8
  • 21
0
votes
0 answers

Java: Executor, FutureTask, Unsafe.unpark - how to prevent printStackTrace?

In Java I am using FutureTask to run a Callable asynchronously via Executor. In order to check if an error occurred from the calling thread, I need to throw potential exceptions from the Callable. This however, leads to the stacktrace printed out to…
Jörg
  • 822
  • 1
  • 10
  • 13
0
votes
1 answer

Android Future vs FutureTask

Is there any reason to use one over the other? They seem to both do the same thing in different ways. I can see that FutureTask is more extensible, but for a simple task where I want to return a future to get a value from later, is there a…
Eliezer
  • 7,209
  • 12
  • 56
  • 103
0
votes
0 answers

Strassen Algorithm Parallel implementation in java

I am trying to implement Strassen matrix multiplication algorithm in both sequential and parallel. I want the following code to run parallel but I have no experience with parallel programming. int[][] M1 = multiply(add(A11, A22), add(B11,…
0
votes
3 answers

selection of future date records from mysql database table

Architecture of my table is as following: I have the above table, wherein date datatype filed "l_from", i want to select all those records which having today date or all the future date from now. For this i have used the following queries: SELECT…
Abdul Rahman
  • 1,669
  • 4
  • 24
  • 39
0
votes
2 answers

Application crashes when UI thread waits for AsyncTask

I am creating an application in Android in which whenever a user receives new Text message (SMS) it is first sent on server and if server replies true the Broadcast is aborted else we Broadcast it. Now the problem is we can not communicate with…