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.net.SocketException: Socket is closed OOP Design bug
How to add more `?` automatically in java in accordance with whatever amount of columns will be placed in the interface
Converting a generic List to an Array. Why do I need use clone?
Calling a method using reflection causes exception
Images in ListView items not filling height
Eclipse Neon, it doesn't import classes under sources inside the IDE
jaxb2 annotate plugin how to annotate a javatype in global binding
ProcessBuilder BufferedReader read() blocking
Why is the program throwing this error??: Exception in thread “main” java.lang.StringIndexOutOfBoundsException: String index out of range: 36
JAVA main with args [duplicate]
java.io.IOException: insufficient data written --on using the java api client for safebrowsing with multithreading
toJson() of GSON library returning wrong json
Java Serialization different Java Version
Java open folder does return the selected folder
Searching a JSON data in Android using ListView
How to add html image in to velocity template file to send email?

Categories

HOME
ibm-bluemix
arduino-uno
openstack
smarty
stock
lodash
objectgears
alfresco
kalman-filter
amortized-analysis
callback
cross-validation
session-variables
dacpac
messages
graphlab
pc
footer
propel
reactcsstransitiongroup
zapier
ml
mps
realex-payments-api
kudan
cultureinfo
h2db
chromebook
gitignore
c++-amp
unboundid
javascriptcore
google-cloud-endpoints-v2
calibre
overlap
main
c11
elasticsearch-plugin
cookiecutter-django
sas-visual-analytics
nomethoderror
galleria
google-datalayer
xml-documentation
scrollable
chain-builder
theming
python-webbrowser
dandelion
sage-one
mu
pg-dump
android-cursor
boost-preprocessor
spring-cache
webdriverjs
or-tools
objective-c-swift-bridge
savon
trash
autorest
qpid
fuzzy-search
lua-5.1
qgraphicsview
pickadate
netmq
r-tree
endeca-workbench
fouc
arcanist
generic-programming
sniffer
cisco-ios
iiviewdeckcontroller
key-management
lustre
c3
tablelayout
markers
sgen
cloud-connect
padarn
pygit2
factory-method
specification-pattern
isnullorempty
rdoc
labwindows
pendrive
oncheckedchanged
google-friend-connect
perfect-hash

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