21
  • What is the difference between green and native threads?
  • Why does it named as green and native?

I'm new to programming world. I love to learn java. while going through the java threads interview questions, i found this. I have heard about thread, but not these green and native. I goggled about green and native threads, but couldn't get an clear idea.

In which case, the thread is said to be green or native?(i mean in programming)

bsiamionau
  • 8,099
  • 4
  • 46
  • 73
Rachel
  • 1,131
  • 11
  • 26
  • 43

1 Answers1

29

What is the difference between green and native threads?

Green threads are scheduled by a virtual machine.

Native threads are scheduled by a operational system.

Why does it named as green and native?

"Green" is earlier JVM threads project code-name. It is name of library, which provided VM-sheduled threads in Java 1.1

Native threads called so because they're belong to native platform.

How do we know that created thread is native or green?

Green threads are in past, JVMs work only with native threads since 1.3

"Green threads" refers to a model in which the Java virtual machine itself creates, manages, and context switches all Java threads within one operating system process. No operating system threads library is used.

"Native threads" refers to a in which the Java virtual machine creates and manages Java threads using the operating system threads library - named libthread on UnixWare - and each Java thread is mapped to one threads library thread.

bsiamionau
  • 8,099
  • 4
  • 46
  • 73