I am using http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html to process different tasks in my app. However, I wanted to carry out certain things (say tracking task start/completion time) before a task has started to run and after the task in complete. I can extend this call and override the beforeExecute and afterExecute method, but I want to avoid that. Is there any other options?
Asked
Active
Viewed 94 times
0
-
Manually: Schedule the before task which upon completion starts the main task which then starts the after task. Related: http://stackoverflow.com/questions/8626033/how-to-use-the-guava-listenablefuture-and-the-futures-chain-methods - or wrap a task in another task (decorator pattern) – zapl Dec 10 '13 at 20:46
-
Hi Zapl, Thanks for your reply. Can you point me to some code examples that covers the decorator pattern approach? – user243655 Dec 11 '13 at 19:57