android里面打印出线程的id的函数是哪个阿 ?

解决方案 »

  1.   

    z= 这个是java的代码把?我的意思是c++ 层的 android里面打印出线程的id的函数
      

  2.   

    楼主很懒用JNI接口使用android方法即可.
      

  3.   

    没明白什么意思?你是在jni里创建线程么?还是说java层创建线程,然后在jni里打引log显示线程的id?
      

  4.   

    getThreadId()->androidGetThreadId()->    pthread_self()或者是GetCurrentThreadId();
      

  5.   

    还是linux的函数
    狂汉  我还搞了半年linux !!
      

  6.   

    Threads.cpp (z:\work\androidcode\23\frameworks\base\libs\utils) 24340 3/24/2011
    #ifdef HAVE_ANDROID_OS  /* valgrind is rejecting RT-priority create reqs */
        if (threadPriority != PRIORITY_DEFAULT || threadName != NULL) {
            // We could avoid the trampoline if there was a way to get to the
            // android_thread_id_t (pid) from pthread_t
            thread_data_t* t = new thread_data_t;
            t->priority = threadPriority;
            t->threadName = threadName ? strdup(threadName) : NULL;
            t->entryFunction = entryFunction;
            t->userData = userData;
            entryFunction = (android_thread_func_t)&thread_data_t::trampoline;
            userData = t;            
        }
    #endif    if (threadStackSize) {
            pthread_attr_setstacksize(&attr, threadStackSize);
        }
        
        errno = 0;
        pthread_t thread;
        int result = pthread_create(&thread, &attr,
                        (android_pthread_entry)entryFunction, userData);
        if (result != 0) {
            LOGE("androidCreateRawThreadEtc failed (entry=%p, res=%d, errno=%d)\n"
                 "(android threadPriority=%d)",
                entryFunction, result, errno, threadPriority);
            return 0;
        }    if (threadId != NULL) {
            *threadId = (android_thread_id_t)thread; // XXX: this is not portable
        }
        return 1;
    }android_thread_id_t androidGetThreadId()
    {
        return (android_thread_id_t)pthread_self();
    }