Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How can i get completion status of runnable object which is dispatched to executor class?  RSS feed

 
Mitesh Soni
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

Thread communication problem.

I have one class say A which periodically cretes runnable object of class B and put it in a queue and then it is dispatched to the executor class for thread execution. lets sat b1 is in execution and at that time new runnable object is triggered and pushed into queue named b2. b2 will be dispatched only when b1 will be completed. now the problem is how i will determine that runnable object which is dispatched to the executor is completed?

what are the ways to determine it? and which is the efficient way?
 
Campbell Ritchie
Sheriff
Posts: 55334
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too difficult a question for us beginners. Moving.
 
Henry Wong
author
Sheriff
Posts: 23275
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
now the problem is how i will determine that runnable object which is dispatched to the executor is completed?

what are the ways to determine it? and which is the efficient way?


The easiest way is probably to use the future object that is returned, when you submit() the runnable object. The future object has a method to determine when the task is done.

Henry
 
Mitesh Soni
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry
 
Henry Wong
author
Sheriff
Posts: 23275
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mitesh Soni wrote:sorry


Sorry for what?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!