AttachCurrentThreadAsDaemon Vs AttachCurrentThread

2,277 views
Skip to first unread message

GoG

unread,
Feb 1, 2011, 6:11:27 AM2/1/11
to android-ndk
Hi,
I have a little question regarding JNI layer.
I use Swig (2.0.1) to generate my wrappers
and I was wondering, which call is prefered
for Dalvik integration :

AttachCurrentThreadAsDaemon() OR AttachCurrentThread() ?

I'm working with real time sensor data processing in some
of my native threads. Is there a function better than the other
(in my case) ?

Thanks a lot.

GoG

fadden

unread,
Feb 1, 2011, 3:47:47 PM2/1/11
to android-ndk
On Feb 1, 3:11 am, GoG <guillaume.au...@gmail.com> wrote:
> I have a little question regarding JNI layer.
> I use Swig (2.0.1) to generate my wrappers
> and I was wondering, which call is prefered
> for Dalvik integration :
>
> AttachCurrentThreadAsDaemon() OR AttachCurrentThread() ?

The VM shuts down when all non-daemon threads have exited. Attaching
a thread as a daemon thread just means that the VM could exit without
having to wait for your thread to detach first.

Android apps don't really "exit", so it's sort of a non-issue.

See also java.lang.Thread.setDaemon(boolean on).

GoG

unread,
Feb 2, 2011, 3:59:18 AM2/2/11
to android-ndk
Ok, thanks for taking time to answer it.
I will keep using the default parameter
used by Swig, i.e. non-daemon thread attach.
Thanks again !

GoG
Reply all
Reply to author
Forward
0 new messages