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

Generics with Hibernate
Access HttpServletRequest using #Context annotaion in business layer
Spring Security OAuth (separate client on angular2)
store map in list using hibernate createSQLQuery method
json jar for JSONOBJECT.getCurrentkey() , jsonobject.getMap()
Building a filter on a collection
Parse the SysML generated from Enterprise Architect in JAVA
Compiler warned me for making a fragment package-private; any other options?
Putting an JPanel into the foreground within another JPanel
Insert text into an XML node located by an XPath expression with Java code
arrayException in thread “main” java.util.NoSuchElementException
My code is not working, Because I didnot know that i am comparing them wrong. [closed]
Spring: Multiple controller instances of same class
Google Maps for android not rendering
Android Studio E/dalvikvm: Could not find class… referenced from method
Spring JDBC - .queryForObject() returns too many results?

Categories

HOME
sendgrid
vbscript
magnific-popup
json.net
fft
jsp-tags
at-command
google-oauth
electronics
jpeg
baqend
android-youtube-api
slurm
offline
imacros
row
fortumo
lombok
predix
jquery-ajaxq
arabic
css-animations
wijmo
dxf
phpfox
fgetcsv
tooltipster
jspm
mmenu
appfabric
scaffold
streamreader
opshub
firebase-admin
sencha-touch-2.3
skeleton-css-boilerplate
termination
promela
boost-multi-index
imanage
query-performance
gnome-shell-extensions
pintos
messenger
root-framework
watchconnectivity
httplistener
whois
browser-link
cartesian-product
libressl
myo
census
composite
angular-local-storage
graph-api-explorer
jsonpickle
java.util.concurrent
nsbutton
java-metro-framework
concurrent-collections
srs
stxxl
floating-point-precision
page-layout
ruby-datamapper
flash-builder4.5
mylyn
django-nonrel
e4x
dmoz
frameset
javaspaces
qtkit
libc++
window-management
blackberry-playbook
locate
floating
web-application-design
gamma
asp.net-profiles
temporal-database
aquaticprime





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