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

Integrating external library into OSGI
JMeter correct location to input a web url? - (Response time required)
JPA and JSON operator native query
Standalone Java Unit Test v/s Tomcat web app
org.hibernate.TransientObjectException: how to properly define one-to-one relationship?
why Encoding in http request?
Accurate tables for Database normalization
Remote Access to Intranet Servers Without Public Ips (perhaps using websockets)
JTabbedPane ArrayIndexOutOfBoundsException: 0
Android turn based multiplayer onTurnBasedMatchReceived doesn't trigger when game starts from Play Games
Robot - Move Mouse to Position with RGB Value
Eclipse Compare Dialog
Enabling Web Request-Response Logging for Spring : Error in Instantiating a Custom DispatcherServelet
in Android ADIF is not supported , what is ADIF , When it needed
Howto organize different project versions that require different Java versions? [Java1.5, Java6, Java8]
The cheapest way to compare two sets of strings [closed]

Categories

HOME
testng
blogger
plone
hp-exstream
tesseract
octobercms
framework7
amazon-ecs
gps
angular-ui-bootstrap
fingerprint
bs4
multiple-records
add
slick-slider
elasticsearch-hadoop
zend-framework3
messages
flask-wtforms
designer
vaadin7
footer
reactcsstransitiongroup
evopdf
ab-testing
excel-vba-mac
beyondcompare
karma-jasmine
arabic
google-search-api
extjs5
chromium-embedded
core-text
status
kannel
rst2pdf
linkerd
maquette
libssl
librato
madlib
flink-streaming
google-rich-snippets
frame
twilio-api
catch-all
host
ios5
git-merge
dartium
espeak
starteam
theano.scan
hilbert-curve
reportingservices-2005
websphere-mq-fte
babel-core
chain-builder
strptime
multipeer-connectivity
python-webbrowser
mu
gabor-filter
tropo
directory-structure
typed-lambda-calculus
android-cursor
dtexec
cudafy.net
gnome-shell-extensions
messenger
savon
underscore.js-templating
transmitfile
skype4py
captivenetwork
php-parse-error
tform
asp.net5
wapiti
browser-link
cartesian-product
teamcity-8.0
t4mvc
django-unittest
citrus-pay
ami
c++03
directoryservices
npapi
fscommand
knuth
applescript-objc
tld
navigationservice
hippomocks
message-driven-bean
intentservice
html5-notifications
terminal-services
ms-project-server-2010
file-locking
hungarian-algorithm
yui-compressor
orchardcms-1.7
http-unit
delphi-6
referrer
fireworks
gwt-ext
xmlspy
self-extracting
recent-documents
winbugs14
mongomapper
cxxtest
yslow
asp.net-mvc-areas
jquery-ui-droppable
data-driven
procedural-music
msdev
django-notification
misv

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App