Distinguishing between Java threads and OS threads?

后端 未结 4 749
小鲜肉
小鲜肉 2020-11-28 01:49

How do I distinguish running Java threads and native threads?

In Linux there will be Parent process for every child process, and they say 0 is the parent of all the

4条回答
  •  失恋的感觉
    2020-11-28 02:13

    There is no generic solution how Java threads are mapped to OS threads, if at all. Every JVM implementation can do it in a different way.

    There is also a pure Java thread implementation, called green threads. This is used as a fallback if native threads aren't supported or the system isn't multithreaded at all. You won't see any green threads at your OS.

    Can a running Java threads can be suspended or killed from another Java code ?

    If they are running at the same JVM, yes, with stop(). But that's not a good solution and may work, or not. interrupt() allows the thread so safely shut itself down.

    There is no way to kill threads outside of the JVM I know of. If a OS really supports killing of threads, I wouldn't expect the Java application to run correctly afterwards!

提交回复
热议问题