user710818
user710818

Reputation: 24248

Why doesn't VisualVM display daemon threads on Linux?

I have a problem with daemon threads on Linux. My application on Windows server works ok, when I create a thread dump I can see whether a thread is a daemon or not.

But when I move my application to Tomcat on a Linux server and create a dump with Java Visual VM I don't see the daemon in the details of threads any more.

Does it mean that daemon threads work only on Windows? And is there some workaround or do we need to close each thread on application exit?

Upvotes: 5

Views: 1366

Answers (2)

Tomas Hurka
Tomas Hurka

Reputation: 6981

It looks like you are monitoring your application via JMX connection. In this case, information about daemon/non-daemon thread type is not available.

Upvotes: 1

Pavan
Pavan

Reputation: 1247

http://docs.oracle.com/javase/6/docs/technotes/guides/visualvm/threads.html - This seems to suggest that Visual VM deals well with both normal and daemon threads. I have used the live monitor in Visual Vm and that works just fine on Linux.

But when I move my application to Tomcat on a Linux server and create dump with Java Visual > VM I don't see the daemon in details of threads any more.

Would it be possible for you to just show a sample output?

Does it mean that daemon threads work only on Windows?

No! Daemon threads work just fine on Linux.

And is there some workaround or do we need to close each thread on application exit?

When a process dies, the OS takes care of reaping all the associated resources, including the threads. So, you do not need to do anything. In fact, just as a side note, JVM does not let you deal with threads' lifecycle directly.

Upvotes: 2

Related Questions