On Tuesday Mar 28, 2000, Norman Shapiro wrote:

> The Java jni specifications require a JNIEnv* for almost all
> functions they provide.  Furthermore it seems that if multiple
> Java threads can access the same function, each function call must
> use the JNIEnv* from the current thread.
> 
> Given that function I am writing is maybe 20 deep in a call
> hierarchy of C++ functions I have written, is there any way of
> accessing the correct JNIEnv* short of passing it all the way down
> as C++ function arguments?
> 
> Putting it in a global or within a global class does not work in
> my case because multiple Java threads can be using the same C++
> function.
> 
> I need a solution that works under Linux, though something that is
> portable to Microsoft* would be ideal.

You could save the pointer in thread local storage, but I guarantee
that it won't be portable.

Take a look at pthread_key_create, pthread_setspecific, et al. 

-John

----------------------------------------------------------------
John Rousseau                               [EMAIL PROTECTED]
SilverStream Software                                           
1 Burlington Woods                        Phone: +1 781 238 5564
Burlington, MA 01803                        Fax: +1 781 238 5499
----------------------------------------------------------------


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to