NDK/JNI: identifying current thread
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In a JNI native method, is there a way to know the ID of the current thread without calling Java back? Thread-local storage would also work. EDIT: pthread.h is present in the NDK include folder... Does anyone know if Java threads correspond to POSIX ones in the NDK implementation? 回答1: Which ID are you interested in? A Dalvik thread dump includes this: "main" prio=5 tid=1 TIMED_WAIT | group="main" sCount=1 dsCount=0 obj=0x40017730 self=0x12798 | sysTid=3167 nice=0 sched=0/0 cgrp=default handle=-2146114456 | schedstat=( 358850000 275073000