java


what does shutdown() really do


From javadoc
Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down.
That is, calling execute() after shutdown() is an error. Sometimes I consider calling shutdown() a rule. Is it just used to forbid new tasks? Without calling shutdown(), what happens?
Mostly it is used to shutdown the ExecutorService i.e. stop it running when you don't need it.
ExecutorServices contain a pool of threads. Threads are never cleaned up by the GC so you can't just discard them and assume the threads will clean themselves up. Once the threads have been told to stop they will do so after they complete the current task or almost immediately if otherwise idle. After they have stopped they can be cleaned up by the GC
NOTE: Any ThreadLocal values will be retained until the Thread is cleaned up.
The shutdown() method prevents clients to send more work to the executor service i.e no new tasks will be accepted and all the existing tasks will still run to completion unless other actions are taken.Invocation has no additional effect if already shut down
The shutdown method (in short)
starts all tasks, that may be submitted, but not yet started (which could be of type Future<E> for example)
forbids submitting new tasks
makes it possible to gracefully shut down

Related Links

Java string comparision logic issue? [duplicate]
Using Spring #Value annotation for multiple properties
protected variable from super class not visible from subclass in different package [duplicate]
Getting the Log4j settings from a custom properties file
JUnit test fails even if the expected result is correct
JNI symbol lookup error
Get array from json in android
Unclear results with jdom2 XPath query [duplicate]
Unable to change the color of buttons on multiple clicks
How accelerate time to serialPort.close(); currently 3 seconds
Display facesontext message in pop up for validating input in a dialog box
Checking if ArrayList contains anything but one element
how to write hibernate mapping for below table structure with composite primary key
org.apache.catalina.core.DefaultInstanceManager cannot be cast to java.lang.String
task restore InterruptionException but cannot catch in Thread
Adding last average value

Categories

HOME
ionic-framework
date
gitlab
pycharm
bookshelf.js
elm
sql-server-2016
mouse
upload
webrequest
fancybox-3
progressive-web-apps
undefined
contextmenu
abi
facebook-instant-articles
php-openssl
one-to-many
status
internet-explorer-9
info.plist
buck
facebook-apps
libssl
quote
r-raster
directx-10
xquery-3.0
siesta-swift
karaf
android-kernel
plsql-psp
qwerty
x11-forwarding
streamsets
c11
elmah
android-mediaprojection
outlook-api
checkboxlist
businessworks
logfiles
dds
statsd
recursive-datastructures
colorama
knpmenubundle
arrow-keys
google-feed-api
firebaseui
multiple-regression
superstack
bluegiga
jmeter-maven-plugin
fouc
muse
map-projections
composite
remobjects
inmobi
network-interface
cdt
gulp-less
castle
dealloc
srs
intentservice
google-cloud-save
bulkloader
ril
objective-c-2.0
bubble-chart
whoosh
php-parser
libc++
window-management
qt-jambi
mod-auth
xmemcached
invite
self-extracting
mongomapper
xfbml
w3wp.exe
subviews
gamma
ext3
uimenucontroller
xetex
post-build

Resources

Encrypt Message