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

acessing the Sonarqube with http://xyz.abc.com:9000
How to run Junit test with xml file
Query in Exception Handling
java regex subtraction of a capturing group
I have two tables (Person and Articles), how can I select all the articles by one individual from the articles table?
Track operation happening at Spring Controller from UI
“Invalid column index” exception in prepared statement
How to get the instance name (instance-id) of a JBoss EAP 7 instance serving the request
Running JUnit test on Controller results in UnsatisfiedDependencyException
Schema Migration
How to decode text cipher Blowfish CFB in Java?
Parse only pos tags into output file
How to restrict that method param of type Class cannot be generic?
Throwable onError component of subscription not compiling as expected
Is there a way to make global variables in java? [duplicate]
Why RecyclerView are under BottomNavigationView?

Categories

HOME
log4j
omnet++
pycharm
json.net
stock
onedrive
android-4.4-kitkat
jsrender
jgroups
webpack-2
windows-server
pheatmap
fancybox-3
dosgi
systemc
google-static-maps
jprofiler
predix
one-hot-encoding
java-3d
jasonette
pass-by-reference
jndi
emgucv
intel-pin
spring-mybatis
strncpy
elasticsearch-net
nat
skia
twilio-api
semantic-versioning
mmenu
mapdb
c11
temporary-files
trim
ncalc
ruby-on-rails-3.1
elmah
isbn
s
slick-3.0
scorm
angular-resource
upstart
clean-architecture
sage-one
gabor-filter
lowpass-filter
tactic
font-size
namecoin
sqlbulkcopy
python-cryptography
nbconvert
jspdf-autotable
webdriverjs
migradoc
root-framework
word-vba-mac
setuptools
fody
ctest
websitepanel
fputcsv
skype4py
qgraphicsview
suffix-tree
tcpserver
teamcity-8.0
libressl
iis-arr
muse
fluid-dynamics
composite
notify
neolane
terminfo
cloud-connect
intentservice
html5-notifications
xsockets.net
jsctypes
excel-2003
sqlperformance
comaddin
mqx
factory-method
specification-pattern
selected
hamiltonian-cycle
nsmanagedobject
gnu-prolog
deobfuscation
javax.script
servicehost
disclosure
mongomapper
cxxtest
multi-tier
eqatec
xetex
wsdl.exe
commodore

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