Re: Is Java VM interface pointer returned by GetJavaVM() thread safe?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Is Java VM interface pointer returned by GetJavaVM() thread safe?

Justin Buser
I think you may be looking at this in reverse, you're attaching your thread to the Dalvik, not vice/versa. In other words it will allow you to operate as you would normally inside of a new thread.

On Wednesday, July 14, 2010 10:32:11 AM UTC-4, Lee Leclair wrote:
I am currently caching the Java VM pointer returned by GetJavaVM() as
a static global reference. Is it safe to access this reference from
multiple threads, or do I need to explicitly protect it with a mutex?

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/KGD2H8VF5HUJ.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
Reply | Threaded
Open this post in threaded view
|

Re: Is Java VM interface pointer returned by GetJavaVM() thread safe?

David Turner


On Wed, Jul 14, 2010 at 4:32 PM, Lee Leclair <[hidden email]> wrote:
I am currently caching the Java VM pointer returned by GetJavaVM() as
a static global reference. Is it safe to access this reference from
multiple threads, or do I need to explicitly protect it with a mutex?

As fadden said, it's not a reference, but you should be able to use it with AttachCurrentThread() without wrapping it around a mutex. Note that all JNIEnv* pointers are thread-specific, so don't cache these into static globals.
 
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.