#include <Jni.h>

#include <string.h>

#include <stdint.h>

#include "android/log.h"

#include<unistd.h>

#include<pthread.h>

 

void *thread_fun(void* arg)

{

    int i =0;

    for(i=0;i<10000;i++)

    {

          __android_log_print(ANDROID_LOG_INFO, TAG, "thread_fun i=%d",i);

    }

    return NULL;

}

 

void TestThread()

{

    int i=0;

    pthread_t pt;

    int rc;

    char thread_name[NAMELEN];

    pthread_create(&pt, NULL, &thread_fun, (void *)i);

    

    memset(&thread_name,0,NAMELEN);

    thread_name[0]='w';

    thread_name[1]='w';

    thread_name[2]='w';

    __android_log_print(ANDROID_LOG_INFO, TAG, "thread_name =%s",thread_name);

    //pthread_setname_np(pt, "new thread");

    pthread_setname_np(pt, thread_name);

}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-08
  • 2022-12-23
猜你喜欢
  • 2021-12-19
  • 2021-10-22
  • 2021-04-12
  • 2022-01-25
  • 2022-12-23
  • 2022-12-23
  • 2021-05-29
相关资源
相似解决方案