Today in France, we celebrate ""
Posts
04/07/10 : Android sorting
16/06/10 : Flex XML parsing
15/06/10 : Android settings
14/06/10 : Pax daemon
10/06/10 : Bundle CPU %
04/06/10 : Wicket CheckBox
03/06/10 : Thread monitor

By tag
Ajax
Android
AspectJ
Flex
Java
JMX
OSGi
Shell
Wickets

Here are some lights and tips on various Object Oriented Programming aspects that I would have dealt with during my software development and architecture activities..., for sharing.

"Beauty is an inexhaustible source of happyness for the one who discovers it" (Alexis Carrel)



Thursday, 3 June 2010

Thread start/stop monitoring

Question : how to monitor a Java thread getting started or stopped ?

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

Previous Post