• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ThreadPoolExecuter --displaying the name of rejected thread.

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.



op:(with 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
 
Bartender
Posts: 5465
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic