Answer : think about the run() method of the Runnable interface.
Details :
Step #1 : consider this AspectJ pointcut definition :
pointcut threadRun() : execution (* Runnable.run());
Step #2 : you can now rely on these 2 respective AspectJ advices :
before () : threadRun() && !cflowbelow(threadRun())
{
System.out("Starting Thread ID : " + Thread.currentThread().getId());
}
after () : threadRun()
{
System.out("Stopping Thread ID : " + Thread.currentThread().getId());
}
The '!cflowbelow' filter controling any reentrant situation.




No comments:
Post a Comment