Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4557650
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:32:19+00:00 2026-05-21T17:32:19+00:00

In a JNI native method, is there a way to know the ID of

  • 0

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 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T17:32:20+00:00Added an answer on May 21, 2026 at 5:32 pm

    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 869 ) utm=23 stm=12 core=0

    “tid” is the VM’s ID.
    “handle” is the pthread_t.
    “sysTid” is the result of gettid() (the Linux process ID).

    The libcore thread ID (obtained from java.lang.Thread.getId()) is not shown.

    (You can obtain the above with “adb shell kill -3 “. The output goes to a common file, defined by the dalvik.vm.stack-trace-file property — usually /data/anr/traces.txt, but it varies by device.)

    EDIT: Every Dalvik VM thread is a Linux pthread. The gettid() syscall will give you a unique ID for each thread. Also, you can add identifying information to TLS in java.lang.Thread or pthread_key.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would it be possible to implement a custom Thread class in Java (using JNI)
The examples for JNI i've seen map Java native methods to implementation by C++
I have an Java applet that loads native code through JNI. Everything worked just
I have a JNI method to access java method which returns an Integer object.
I have some JNI code in a thread that calls from Java to C.
I have the following JNI method that creates a collection of Java objects natively,
I'd like to pass java class object to JNI method, And I want to
I would like to monitor the following system information in Java: Current CPU usage**
I am currently working with JNI (Java Native Interface) to send data between Java
I'm trying to call a java method from native C code in an Android

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.