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

ANTLR 4 target language generation
Run methods in a thread
Do I have to explicity close all streams, if they're wrapped in a buffer via java?
Download video from URL and store it in android device
JAX-WS and CDI not working together on WAS Liberty Profile 8.5.5.6
java command line requires JDK on Mac?
Android Studio 2 Activities [duplicate]
ActionBarActivity crashes my app [duplicate]
How is this JMH microbenchmark skewed, if it is?
Having problems while trying to remove user generated todos using a recycler view?
Selenium webdriver not responsive after click
Regex to validate only 0 value. Single 0 value to be validated
Is using serialization to store data in a single file a bad idea?
Spring 4 and hibernate 4 EntityManager instance is null
Why does java support different types of JVMs such as CVM, KVM?
jBloomberg api to get stock quotes exception

Categories

HOME
variables
clips
include
hp-exstream
fft
syntax
react-redux
infragistics
frameworks
v8
angular-ui-bootstrap
datastax-java-driver
azure-storage-tables
swagger-ui
node-notifier
pheatmap
spring-tool-suite
gz
leiningen
windows-server-2012
quickfix
fatal-error
finite-automata
aurigma
excel-vba-mac
django-cms
textfield
swingx
custom-wordpress-pages
functional-testing
underflow
status
buck
saas
subdomains
file-rename
flink-streaming
frame
phpfreechat
bower-install
host
dartium
jquery-bootgrid
lto
android-fingerprint-api
dism
ruby-on-rails-3.1
jvm-languages
firebase-admin
android-mediaprojection
estimote
flashair
sencha-touch-2.3
wptoolkit
hls.js
tropo
recursive-datastructures
pillow
epson
sqldf
iso8601
spring-cache
medium.com
passport-google-oauth
probability-density
ctest
qpid
lua-5.1
essence
netmq
srand
wireshark-dissector
ionic
ibaction
ideamart
fscommand
rake-task
qpainter
codeigniter-routing
has-many-through
sgen
rebol3
hippomocks
jboss-weld
centos5
industrial
floating-point-precision
buster.js
sqlperformance
mqx
simba
quickdialog
hosts-file
wse3.0
vc90
webkit.net
brewmp
audio-capture
port-number
dbisam
ntvdm.exe

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