java java中的绿色线程和Native线程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15267269/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Green threads and Native threads in java
提问by Rachel
- 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.
我是编程世界的新手。我喜欢学习java。在通过 Java 线程面试问题时,我发现了这一点。我听说过线程,但没有听说过这些绿色和原生的。我盯着绿色和本地线程,但无法得到一个清晰的想法。
In which case, the thread is said to be green or native?(i mean in programming)
在哪种情况下,线程被认为是绿色的或本地的?(我的意思是在编程中)
回答by bsiamionau
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
“Green”是早期的 JVM 线程项目代号。它是库的名称,它在Java 1.1 中提供了 VM 调度线程
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
绿色线程已成为过去,自 1.3 以来 JVM 仅适用于本机线程
"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.
“绿色线程”是指一种模型,其中 Java 虚拟机本身在一个操作系统进程中创建、管理和上下文切换所有 Java 线程。不使用操作系统线程库。
“原生线程”是指Java虚拟机使用操作系统线程库——在UnixWare上命名为libthread——来创建和管理Java线程,每个Java线程映射到一个线程库线程。