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

How to cope with differences in the GET and POST JSON scheme of WP-API
Why using Guice Provider instead of normal injection
Hibernate does not merge entry
Evaluate formula and remove formula from cell
Jersey with jackson
Server-Client in java using TCP/IP.Cannot send/receive messages
Remove all cookies from specific domain in web view
how to compare value of a row in database table to a string in jsp
If a jar file is required by multiple web applications?
Want to insert into secondary table wtih foreign keys but not in primary when name is the same
go to end of line of a textbox in appium
Weird error in subclass with file name [closed]
RxJava expiring subscription
EJB Pool and EJB defined in 2 EAR
Do Design Patterns matter in Data Driven programs? [closed]
Topological Sort in Java

Categories

HOME
maven
xamarin
arduino-uno
testng
server
pycharm
relative-path
appx
view
grep
paw-app
ip
flyway4
pheatmap
applepay
iggrid
qt-creator
gz
serverless-framework
aurigma
samoa
nodatime
physics-engine
intentfilter
core-text
cultureinfo
icloud-api
one-to-many
phpfox
kendo-datasource
unboundid
gsoap
contact-form
scorm2004
kendo-ui-grid
textmate
appfabric
jquery-bootgrid
retina-display
code-search-engine
sas-visual-analytics
fedex
reportingservices-2005
chain-builder
promela
tropo
directory-structure
magma
font-size
dtexec
ifs
akka-cluster
memory-alignment
zendesk-app
mcafee
dwscript
yt-project
watchconnectivity
setuptools
dstu2-fhir
fody
py2app
system.management
lib.web.mvc
iis-arr
php-ci
sysinternals
cisco-ios
system32
oberon
xc16
camanjs
file-copying
issuu
terminfo
project-planning
android-2.2-froyo
intentservice
dotnetnuke-5
sabredav
type-equivalence
ocunit
android-hardware
selected
sublist
ocx
wse3.0
uiviewanimation-curve
netbeans-6.9
amazon-appstore
asyncfileupload
adk
libc++
hirefire
mod-auth
subgurim-maps
xmemcached
horizontal-accordion
propagation
xfbml
lpeg
modelstate
rescale
multi-tier
text-coloring

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile