[ JCCF ]
[ java APIs ]
[ JNI and Multi-threading ]
JNI and Multi-threading
Java includes a direct support for multi-threading. But the most
important part of this support is used through Java methods and
Java classes. So, it can be used in native code just by using the
technics seens so far. The only syntatic feature uses keyword
synchronized to take control of a monitor associated with an
object. Thus, the JNI proposes two methods: MonitorEnter and
MonitorExit that we can use to indicate the start and the end
of a syncronized piece of code.
This class, Register, implements a bounded register,
addition is permited only if the value remains betwen the bounds. Otherwise,
addition blocks untils the condition (to remain between the bounds) holds.
The native code uses both synchronized code
and callbacks to java thread-related methods.
Links to source code :
Makefile
Register.h
UseRegister.java
Register.java
Register.cc
©
Alain.Miniussi@labri.u-bordeaux.fr
Last updated = june 12th 1997
url =
native/registerV4/index.html