multithreading - Seeking Clarity on Java ScheduledExecutorService and FutureTask -


I'm just starting the Futures and Scheduled Exclorse service in Java, and I wonder why I am not able to call I have been running at the scheduled time. In this sample code, the colabal runs once, but the app never completes, nor does the task run again, which is expected to happen to me (I'm sure the problem With my hope).

Runnables work fine; Calls are always getting blocked, but I'm not sure why ... what am I missing?

Thank you! Public class executable example {/ ** * @ Param args * @throws ExecutionException * @throws InterruptedException * / public static void main (string [] args) Disrupts Exception, ExecutionException {ScheduledExecutorService scheduler = Executors.newScheduledThreadPool (5); FutureTask & LT; ArrayList & LT; String & gt; & Gt; Ft1 = new Future Tasks & Lt; Outerst & lieutenant; String & gt; & Gt; (New callable & lt; ArrayList & lt; string & gt; & gt; () {@Override public ArrayList & lt; string & gt; call () {ArrayList & lt; String & gt; stuff = new ArrayList & Lt; String & gt; (); (Int i = 0; i & lt; 10; i ++) {string thing = "add" + "+" for the result "; stuff.add (object); Out.printline (chees);} return content;}}) Scheduler schedulatet fixtures (FT1, 0, 1, time unit SEOCNDS); println (ft1.get ()); println (ft1.isDone ()); }}

The problem is that using FutureTask Goes, and its "Once computation is complete, computing can not be restarted or canceled."

after running method FutureTask

Can be used as, and does not allow it to return a result instead Give a callback to the Runnable task, which can apply it at the end of its run method, to report the results of each execution of the work, to listeners to other threads Can send back


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -