1

in my Android App I'm using a single thread executor and every 300 milliseconds I create a new MyRunnable and I call the method execute() of my SingleThreadExecutor. Now my goal is to recycle the Runnable object. But I don't know when and How I can release the Runnable .. CoUld you help me ?

Some other details : My class that implements Runnable is called MyRunnable and inside that there are the method to set and reset the MyRunnable params. Every 300 milliseconds I create new MyRunnable and I set all data before call the execute method.

aeroxr1
  • 1,014
  • 1
  • 14
  • 36
  • 1
    What do you mean by recycling a Runnable? Isn't that simply a reference? – Sabir Khan Dec 17 '15 at 07:41
  • Inside Runnable I have some parameters to set , and for that i'm not using sonly one runnable instance. – aeroxr1 Dec 17 '15 at 07:42
  • 1
    See if this existing question helps - [Best way to reuse a Runnable](http://stackoverflow.com/questions/2774252/best-way-to-reuse-a-runnable) . Thread pools make you work with fixed number of threads so re usability of Runnables is solved there. If you don't wish to recreate some fields inside your Runnable then use setters to reset those values. – Sabir Khan Dec 17 '15 at 07:54

0 Answers0