My RCP is stuck inside a DLL file

I am developing an RCP program in Java that calls some APIs from a DLL file via JNI (Java Native Interface). The dll file is also developed by me.

The API (we call it A) is used to get some data and it can take a long time. So I developed another API (called B here) to reverse the processing of A and return the already calculated data (e.g. maybe 50% of the expected data) back to my RCP. In my RCP I have 2 threads, one as a background thread waiting for the result from A, the other a dialog with a cancel button so the user can cancel it. When the Cancel button is clicked, B is called. So B can cancel busy A. Now the problem arises. When I click the Cancel button, A does not return any data. But it works if I run two RCPs in parallel and use one RCP to cancel the other.

It seems that I have some conflicts when using 2 threads in one process to access the JNI, working well with separate processes.

I want to know what is really going on here? How does JNI split multiple threads / processes? How to avoid getting stuck in a DLL?

Many thanks!

+3


source to share





All Articles