• Post Reply Bookmark Topic Watch Topic
  • New Topic

OCP Java 8 Flashcard Set 1 Card #56 (Sybex)  RSS feed

 
Donald Colvin
Greenhorn
Posts: 13
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Flashcards Set 1 Card #56 Definition says,
The shutdown() method prevents new tasks from being added and waits for all previously submitted tasks to finish.  The shutdownNow() method does the same except that it attempts to stop all running tasks and cancels any tasks that have not been started yet.
The text "and waits for all previously submitted tasks to finish" should either be deleted or corrected to reflect that neither shutdown() now shutdownNow() wait for tasks to end (see JavaDocs).
 
Scott Selikoff
author
Bartender
Posts: 4093
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I think this is a semantics issue.  By "waits", we were referring to the fact that ExecutorService itself will wait for the tasks to be finished.  In other words, if a task is currently running and shutdown() is called, the ExecutorService will wait for that task to finish before completing shutdown.  In no way did we mean the method call itself actually waits.  For that, you would need awaitTermination().  Sorry this wasn't clearer!
 
Donald Colvin
Greenhorn
Posts: 13
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that makes sense, but it was not worded as such on the flashcard.  (I actually just took the exam this afternoon, and I got one question where, had there been a System.out.println call after the call to shutdown, knowing that distinction could've made the difference in getting the answer correct vs. incorrect.  But there wasn't, so maybe it's not important for the exam, just for real life.  )  Thanks for the speedy response!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!