I am a java developer, I was studying Multi-threading. Correct me if I am wrong, I have understood that threads made by java/jvm are created in OS. So my question is that, is thread created with java is same as thread created in C++?
-
Comparison of Java and C++Chris K– Chris K2014-11-25 15:33:24 +00:00Commented Nov 25, 2014 at 15:33
-
2this is rather a broad question, but i hope that it'll help you: when you create an OS thread, it's the same as any other OS thread regardless of the language you wrote it inNo Idea For Name– No Idea For Name2014-11-25 15:35:21 +00:00Commented Nov 25, 2014 at 15:35
-
thxn @NoIdeaForName thats what i was thinkingprsutar– prsutar2014-11-25 15:38:34 +00:00Commented Nov 25, 2014 at 15:38
-
@NoIdeaForName if you read the link in wikipedia provided by ChrisK you will notice that there are differences despite the programming language used e.g. optimization.Luiggi Mendoza– Luiggi Mendoza2014-11-25 15:44:03 +00:00Commented Nov 25, 2014 at 15:44
-
3Remember, a JVM is a Java Virtual Machine. It is possible for a JVM to implement threads without using native threads to do it. Some people call those simulated threads "green threads". But, any production-quality JVM will create one native thread for each Java thread.Solomon Slow– Solomon Slow2014-11-25 15:47:38 +00:00Commented Nov 25, 2014 at 15:47
1 Answer
Java threads (in the long ago) were implemented with non-native threads called Green threads.
More modern versions of Java do utilize native threads which are similar to C++ threads but are a bit more abstract. Further, there still might be a many to many relationship between Java threads and the native OS threads (see Query by Slice, Parallel Execute, and Join: A Thread Pool Pattern in Java and of course a M:N model is pretty much mandatory on Windows) in which case they are still built on native threads but they are not (necessarily) isomorphic (1:1) to native threads.