How many thread types are in java?(i know only one daemon thread)
posted 9 years ago
Hi These are some of the JVM thread types, I know :
1. Daemon threads - used in the background to implement a service. To create daemon thread thread.setDaemon(true). JVM exits when the only running threads are daemon.
2. Green threads - are pseudo threads. These are user level threads. Sun wrote green threds to enable thread support where native threds cannot be used. But I am not sure, if that means that green threads **CANNOT** be time sliced or round robin'ed. However this should depend strictly on the scheduler.
3. Native threads - To create native thread you need to run native VM use "-native" option. These threads can definitely be scheduled by OS scheduler.
I am not sure if Sun's Hot Spot VM still uses green threads on Solaris. But if they do then I think it shouldnt run faster than native implementation.
"Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover." - Mark Twain