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

Accessing Files From Java Applet [duplicate]
2D elastic collision not working properly
Tomcat-7 Error while starting in eclipse Luna, Error starting static Resources
How to design a Pseudorandom Number Generator-Pattern which can be used for testing?
Java, protected access of methods of nested subclass not working. Forced to public [duplicate]
(Spring Security Crypto Module) encrypted data Search
I download an image from the internet with a service. How do i show it?
Java MVC and Action classes
Change a string in one class from another class. Android
hashmap and arraylist connected
Open every link in loop (Selenium)
VisualVM profiler throws null pointer exception for empty main
Change parts of a string
Some javafx classes cannot be resolved in Eclipse using Java SE 8u25
How to deserialize this json
pass jsp parameter to another using button

Categories

HOME
java
vim
ionic-framework
proxy
google-play
layout
relative-path
session
platform-builder
xmpp
yum
cross-validation
iggrid
floating-action-button
qt-creator
remote-access
quickfix
ups
netflix
tostring
pc
fatal-error
text-rendering
contextmenu
viewport
amazonsellercentral
autocad-plugin
cloudhub
mps
tapestry
strncpy
tasklet
xquery-3.0
siesta-swift
code-contracts
caret
stringtemplate
lxd
amazon-kinesis-kpl
git-merge
space-complexity
sqlite2
broadcastreceiver
no-www
mime
flashair
wptoolkit
smartcontracts
errordocument
togetherjs
carrot
windows-mobile-6.5
linode
imanage
dynamics-sl
httplistener
login-control
merge-conflict-resolution
storekit
contact-list
lua-5.1
pagedlist
make-install
design-by-contract
photobucket
browser-link
ruby-2.2
atk4
wireshark-dissector
pundit
ibaction
census
lustre
dd
asp.net-web-api-odata
wordpress-theme-customize
xojo
xceed-datagrid
algebraic-data-types
aqtime
rabl
spring-validator
distutils
pvrtc
funscript
dice
ocx
chrono
uiviewanimation-curve
netdna-api
data-loss
hamachi
ecl
disclosure
icanhaz.js
libs
windows-live-messenger
rtml

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