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

Failed to start component - ZipException: invalid LOC header (bad signature)
How to perform unbuffered input in Java (if at all possible)? [closed]
MySQLSyntaxErrorException when trying to update using java database [closed]
Are exception flow control better in certain scenarios?
How to send notification to android phone from Bluetooth Low Energy beacon?
QuerySyntaxException Object not mapped
How do i implement my runnable to check recursivly?
I am trying to declare an array from my main class with setters
JSOUP- Trying to find a specific a href
Get class from ArrayList
Build map with column name and column values from java.sql.ResultSet
Sticky DB connection pooling
Sorting Java Map by List values
Search by name using Spring MVC
reading an multiple blob as byte Array in java and display everything in PDF
How to reference TFS work item when committing from Eclipse EGit or from git command line?

Categories

HOME
winforms
gitlab
netbeans
openstack
include
raspberry-pi
platform-builder
xmpp
getelementsbytagname
jsrender
jgroups
jpeg
survey
ip
retrofit
enterprise-library-5
wamp
django-imagekit
android-youtube-api
esper
ssl-client-authentication
spring-tool-suite
moonmail
commonmark
orchardcms
pythonanywhere
google-pagespeed
nodatime
jtextfield
swiftlint
autoconf
jasonette
tapestry
tibco-mdm
hammerspoon
su
semantic-analysis
fifo
windowbuilder
srcset
r-raster
nameservers
titanium-mobile
protovis
bower-install
jmonkeyengine
impersonation
bootstrapper
gzipstream
powershell-dsc
atomicity
domain-model
libusb-win32
font-size
akka-cluster
python-cryptography
mako
flow-control
vtigercrm
libpng
ado.net-entity-data-model
phishing
player
phpcas
comobject
security-testing
dukescript
cakephp-3.1
nsight
system32
web-controls
streambase
ng-animate
tt-news
fpml
onactivityresult
dml
bundles
hyprlinkr
terminal-services
uv-mapping
farseer
gwt-rpc
ember-app-kit
lcs
flashvars
android-hardware
robotics-studio
path-separator
chuck
funscript
hosts-file
custom-backend
zpt
yui-datatable
sudzc
h.323
getresponsestream
asp.net-profiles
vc90
iweb
text-coloring
genealogy
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