• Post Reply Bookmark Topic Watch Topic
  • New Topic

ThreadPoolExecuter --displaying the name of rejected thread.  RSS feed

 
luke brown
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i just executed the below code which runs fine but i want to see which thread the is being rejected (not being accomodated in the blocking queue for a while).though this is visible using the runnable.toString() but i am using currentthread and the output reads main thread rejected thrice.



opwith toString())


op:with currentthread.getname()


why it is showing up main thread while using currentthread methed?
and how can i write toString override for Runnable object here?

thanks
Luke
 
Piet Souris
Master Rancher
Posts: 2041
75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Luke,

you could create a decent class that implements Runnable, and give it some identifier
member, something like "I am Runnable '...'".
You can also do this by extending Thread.
Then, in your main method, use instances of this class, giving them unique identifiers
as you start them.

In your RejectedExecutionHandler you can simply print this identifier.

Greetings,
Piet
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!