Reputation: 41
Suppose the java method method A()
calls the native method read()
to read something. Is A()
invoked on the same thread as read()
?
A()
is under the JVM's control, but isn't read()
controlled by the system?
When read()
got some data, how can it know that the data was requested by A()
but not B()
or C()
? How can the JVM get the data that was returned by read()
?
Upvotes: 0
Views: 128
Reputation: 57173
Usually in JVM native calls are performed through JNI in the same thread. In modern JVM, Java threads are implemented as native OS threads. When Java method A calls read(), it may switch from managed to native, but it behaves just as a normal synchronous function call.
Upvotes: 1