Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get running thread from SchedulerThreadPoolExecutor

 
Tim Lim
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I have some problems using SchedulerThreadPoolExecutor.

I wanted to get the Example class implement Runnable. Below is the code snippet


From the API documentation, I can see that there is this getQueue() method that will get BlockingQueue<Runnable>. However, when I try to run through a loop for the BlockingQueue,
I have found that the Runnable contains an instance of ScheduledFutureTask. I could not find a way to get the Example class that I implemented. In addition, I don't see a method that will return a list of running task. So my question are:

1) Is there a way to get Example class that I implemented from the scheduler?
2) Is there a way to keep track of the running task since getQueue() return a list of runnable which are not running?
3) I wanted to implement a code that will stop a task in the event if all 3 attempts of retry failed. So how should I do it?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic