Does anyone know how is Java concurrency implemented for Windows? Does it call the native Windows API? I downloaded the source code from OpenJDK. So far, I haven't found any file related to concurrency. Thanks.
-
http://www.tutorialspoint.com/java/java_multithreading.htm ? – TheBlastOne Feb 01 '13 at 14:11
-
@TheBlastOne The question is about the *implementation*, not about the API. – Feb 01 '13 at 14:13
-
1it has to call the native windows api eventually, and Thread.start is a native method. is the question where to find the code that calls the windows code? – Nathan Hughes Feb 01 '13 at 14:26
-
1[This](http://hg.openjdk.java.net/jdk7/jdk7/hotspot/file/tip/src/share/vm/prims/jvm.cpp) should get you started (look for StartThread) - [Windows specific files](http://hg.openjdk.java.net/jdk7/jdk7/hotspot/file/9b0ca45cd756/src/os/windows/vm/). – assylias Feb 01 '13 at 14:31
1 Answers
You're probably referring to the two thread models used throughout the history of the Java Runtime: the green thread model (user-level threads, managed by the JVM) and the non-green thread model (native threads, managed by the OS).
As answered here, green threads aren't used anymore (and haven't been used for a long time) on any of the popular platforms (Windows, Linux, Solaris). So, to answer your question, Java threads are real threads at the implementation level.
The synchronized
keyword functions based on the fact that every object is associated with a "hidden" monitor. Therefore, synchronized
works by emitting the bytecodes for monitorenter
and monitorexit
, which are instructions to the JVM to lock and unlock respectively that hidden monitor.

- 1
- 1

- 28,773
- 8
- 68
- 104
-
yes, but i need an answer to other concurrency constructs too, not just threads. – Candy Chiu Feb 01 '13 at 14:30
-
@CandyChiu I've added a small description for `synchronized`. Can you name what other constructs you're interested in? – Theodoros Chatzigiannakis Feb 01 '13 at 14:38
-
this is not enough. i want to know details such as whether they used kernel objects (mutex) or user mode objects (critical region). I am digging around openjdk's source. I will eventually come to something. I was hoping someone has already done the digging and point me to the files. – Candy Chiu Feb 01 '13 at 15:05
-
@CandyChiu I think you should include these details to your question, so it has better chances if someone can help you about those specific aspects. – Theodoros Chatzigiannakis Feb 01 '13 at 15:57