Question

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

Was it helpful?

Solution

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top