Ahmed
Ahmed

Reputation: 15069

does JNI introduce an extra thread for native code?

I currently using android NDK to write some native code in C. I have learned that using JNI we can make two way calls from java to C and from C to java.

I am curious if using JNI introduces an extra thread implicitly or is it still one main() thread for the app ?

Thanks,

Upvotes: 2

Views: 426

Answers (1)

Sergey K.
Sergey K.

Reputation: 25396

Dalvik Java VM in Android calls the native code from the current Java-thread. It can be any thread - UI or any other. Your native code is free to spawn new threads at will.

Of course, the call java->native->java will return to the same thread it was invoked in.

Upvotes: 3

Related Questions