Win a copy of Functional Reactive Programming this week in the Other Languages forum!
    Bookmark Topic Watch Topic
  • New Topic

Threads in Java

 
Kontham Satish
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Report post to moderator
How many thread types are in java?(i know only one daemon thread)
 
Nishant Verma
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Report post to moderator
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.

Cheers
Nishant
 
    Bookmark Topic Watch Topic
  • New Topic