Call Java Method from A Second Native Thread.

Dear All,

I am working on an application to monitor the state of a device. The device monitor part is written in c as native code. The java part of this application should be notified by the native part when there is something happens. The basic work flow is:

Java: Call native function Init.

C++ : Create device monitor thread and return.

.

.

Hardware: An event happens.

C++: Be notified by Windows message loop and try to call a method in java (but how? This is my question.)

Java: A method is called by c++ part.

.

.

(when java part devide to finish the job)

Java: Call native function Exit.

C++: Destroy device monitor thread and return.

So, anybody knows how to call a java method from a second thread in the native code?

Please let me know if you have any clue.

Best regards,

Chris.

[898 byte] By [Chris_G.a] at [2007-11-26 22:42:46]
# 1
Hi,You should have a look at the Callback mechanism in JNative sources.You can start at http://jnative.cvs.sourceforge.net/jnative/JNativeCpp/CallBack.cpp?view=markup--Marc ( http://jnative.sf.net)
mdentya at 2007-7-10 11:58:35 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
> So, anybody knows how to call a java method from a> second thread in the native code? > The same as doing any call in JNI code except that you have to register the thread with the JVM before doing anything (there is a method for that.)
jschella at 2007-7-10 11:58:35 > top of Java-index,Java HotSpot Virtual Machine,Specifications...