views:

253

answers:

2

Is there a way to monitor how many threads are actually alive and running my scala actors ?

+2  A: 

You might try the VisualVM tool (available free from Sun). Among other things, it can monitor threads in running JVMs.

Randall Schulz
But won't tell *paradigmatic* which threads are actually servicing the actors
oxbow_lakes
The threads serving actors will likely have special names to distinguish them from VM threads. If a thread is not a VM thread and was not created by you, it's probably an actor thread. So +1.
Seun Osewa
@Seun - unfortunately they have nothing of the sort. Depending on whether you are running Scala 2.7.5 or 2.7.7 they are either `Thread-N` or `pool-N-thread-M`. The only correct answer to this question is to inject your own scheduler
oxbow_lakes
+3  A: 

The only way to properly do this is to inject your own executor for the actors subsystem as, by default, the actor threads do not have actor- or scala-specific names (they may just be called Thread-N or pool-N-thread-M depending on which version of Scala you are using.

Philip Haller has given instructions on using your own executor, where you can monitor thread usage if you wish, or at the very least name the threads so created. If you override thread naming you could then use the standard Java system MBeans (i.e. ThreadMXBean) to monitor the threads programmatically (or via the JConsole/JVisualVM).

Note that you can control the default mechanism using the system properties:

  • actors.minPoolSize
  • actors.maxPoolSize
  • actors.corePoolSize
oxbow_lakes