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 get our own Wireless LAN Ip address using java
Android Compare two spinner and intent to new activity [closed]
How get backgroundColor from ImageView [duplicate]
Java linkedlist - How to copy data?
Add an app to list of content providers of attachment to email?
Spring conditional property validation
Creating a method that returns true if the specified number is “everywhere” in the integer array
Using Spring Batch to write csv records to different SQL tables based on a field value [duplicate]
WebView Configuration
Menu structure and while loop?
Generating lines at an increment
Given two 2D arrays, add them into a third 2D array
setOnClickListener on a imageview
User-subscription entity relationship in Spring-hibernate
Retrieve scores for each document Neo4j Lucene, not just the order
Java: process annotation inherited from .class file

Categories

HOME
pandas
yii2
amazon-ec2
single-sign-on
dictionary
onedrive
lodash
relay
sqlite-net-extensions
binary-tree
webpack-2
disassembler
retrofit
ebean
opengl-es-2.0
google-translate
mapserver
nstableview
moonmail
fortumo
finite-automata
beyondcompare
contextmenu
one-hot-encoding
css-animations
tapestry
captiveportal
jndi
one-to-many
elasticsearch-net
dbclient
jaxb2
newline
gsoap
xquery-3.0
fog
avcapturesession
restlet
az-application-insights
reportbuilder
webdriver-manager
cookiecutter-django
g-code
atomicity
logparser
clean-architecture
datastax-startup
webdriverjs
redundancy
color-picker
ado.net-entity-data-model
database-optimization
nsfilemanager
yaws
oauth2client
ios8-today-widget
lemon
nsight
formatjs
website-monitoring
clicktag
dd
jscript.net
qpainter
rdtsc
code-access-security
castle
jquery-layout
mysql-error-1062
rtmfp
message-driven-bean
prettify
tidy
dbconnection
dotnetnuke-5
eclipse-memory-analyzer
seed
browser-detection
quickdialog
cisco-jtapi
runas
tridion-worldserver
punbb
joyent
winbugs14
imac
simpletest
phonon
pascal-fc
defensive-programming
msdev
paul-graham

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