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

Run contents of string in java [duplicate]
Java extends from class with <class name>
Android background timer updating a Texview Item of Recyclerview
How to gzip file in place replacement Java
To convert ruby unpack equivalent in java
Error message in Java after extending JFrame
Replace XML element with Java
poker game straight in java
Data and Database Storage in Different Regions of AWS
how to add xml node into an element
connect server with rest API ,for that i added jar files in my libs folder ,and dependencies , it showing errors like this
Printing Last Index of a String without using lastIndexOf()
Change value of an EditText of another position of a ListView from the Adapter
#Scheduled not working : Spring 4
Which App Engine Maven Plugin to use?
how to prevent user from entering decimal values in integer fields in REST APIs in spring in java

Categories

HOME
ms-access
winforms
wso2-am
variables
jdo
pypi
netbeans
electron
relay
google-docs
yarn
enterprise-library-5
mouse
contact
elasticsearch-hadoop
nano-server
quicklook
modelica
export-to-csv
google-cloud-spanner
php-7.1
spring-tool-suite
ibm-odm
quickfix
solaris-10
shared-hosting
grails3
jasonette
arabic
accessor
extjs5
core-text
format-specifiers
pepper
gsmcomm
fabric8
cloud-code
google-api-nodejs-client
html5-fullscreen
serverside-rendering
streamreader
azure-ml
user-controls
sql-server-agent
bootstrap-dialog
websphere-mq-fte
jsch
user-accounts
scrollable
termination
worksheet
mplayer
brightcove
sqlbulkcopy
memory-alignment
mako
deadbolt-2
xml-attribute
livequery
tform
asp.net5
appfabric-cache
mono-embedding
web-controls
skos
lustre
sorl-thumbnail
angularjs-ng-click
html-helper
starcluster
yorick
ember-charts
algebraic-data-types
monomac
intentservice
runtime.exec
flash-builder4.5
cos
shellexecute
spring-validator
ocunit
semantic-diff
pendrive
whoosh
django-tagging
invite
dmx512
routedevent
fixed-width
anti-piracy
text-coloring
port-number
mediarss

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile