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

calling Java method from jsp page
Application at context path / could not be started - Tomcat 8
GSSException createCredential
static method called from constructor in Java
How to auto configure war file in eclipse
Start Connection JMS?
Xamarin and APK Signing - Change path to JarSigner
PlayFramework. How to upload a photo using an external endpoint?
Read Mysql Database After Event came to Esper Engine?
android radiobutton button accept
Adding an actionlistener to a JButton
replacing guice 3.0 with 4.0 beta
Code not printing anything
Why is sonar-runner analysis stuck in infinite loop at “Updating semaphore”
Count numbers below 45 in a Linked List
How would I create a Highest Score counter for this program & where would I place it?

Categories

HOME
maven
openlayers
osgi
comparison
electron
relay
rsyslog
spring-cloud-stream
rubygems
fingerprint
yum
opengl-es-2.0
in-app-purchase
ios-charts
contact
quicklook
spring-tool-suite
n-gram
remote-access
flask-wtforms
iron-router
django-admin
facebook-page
serilog
connection-string
clickonce
orleans
extjs5
mmap
php-openssl
android-widget
sqlcipher
pepper
maxmind
gitignore
kendo-datasource
unboundid
instant-messaging
data-manipulation
exuberant-ctags
winrt-xaml-toolkit
pim
windows-dev-center
amazon-kinesis-kpl
mapbox-gl
wpf-controls
overriding
restlet
automake
gesture
event-driven
mapzen
dynamic-reports
google-closure
mime
convertapi
zip4j
hendrix
clean-architecture
datastax-startup
mu
qtwebview
pdfclown
flow-control
spring-cache
color-profile
pycaffe
android-textview
radtreelist
bonobo
mikroc
nsfilemanager
whois
pagerank
associative-array
google-places
marching-cubes
map-projections
arcanist
sailfish-os
fluid-dynamics
sniffer
web-controls
tween
jsonpickle
gulp-less
castle
yorick
valuechangelistener
dealloc
ember-charts
typo3-neos
intentservice
cdc
flash-builder4.5
random-seed
http-unit
bigcouch
nsdatecomponents
yui-datatable
coda-slider
gin
mtj
dbisam

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile