I'm trying to shut down the understanding of the executable service relative's behavior. The documentation says that unless a shutdown (call) is done, the application will not end - but in this simple example, it goes out immediately after one minute. Any idea
Runnable R = New Runnable () {@Override Public Zero Run () {Print.println ("nothing"); }}; ThreadFactor TF = (Runable Run) - & gt; New thread (run); Executable service exec = executable. NUKEED and POOL (TF); Exec.submit (r); This return: 11: 34: 00.421: Thread-0: Nothing like BUILD succeeded (total time: 1 minute 0 seconds)
You are using CachedThreadPool. This thread keeps the thread alive for 60 seconds so that it does not waste time in creating new thread resources in the next station.
Internal Code -
Public Fixed ExecutorService newCachedThreadPool () {New ThreadPoolExecutor (Return 0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, New SynchronousQueue & Gt; ()); } Once you've made the call (should call).
No comments:
Post a Comment