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

  • SEARCH
  • Home
  • 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 8481363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:32:33+00:00 2026-06-10T19:32:33+00:00

I had a look at existing questions on getting the thread id like java-thread-id-and-stack-trace

  • 0

I had a look at existing questions on getting the thread id like java-thread-id-and-stack-trace .

But I’m not able to figure out something that seemed simple. I want to make a JSP tool to stop a thread in Java.

I know it’s a bad idea in general but we need it as we can’t use JConsole in our environment cause some hardening of JBoss.

My questions are, take a sample jstack output:

  1. Event Batch Processing (Spring UAA/1.0.2)" daemon prio=10 tid=0x0000000041e27800 nid=0x363b waiting on condition [0x00007f9a89267000]
    From this which id would be the thread.getId() as defined in java.lang.Thread? What is the last token in this line [0x00007f9a89267000]?
  2. How do I convert (Java code would be super) the hex to a Java long?
  3. Could you tell me why this did not work -> I took a hex tid= from a jstack of a thread that was hung in a never ending loop. I then did this:

    Thread thrd = null;
    String thrdId =request.getParameter("thrd");
    if(thrdId != null){
        out.print("thread " + thrdId + " :");
        out.flush();
        Map<Thread,StackTraceElement[]> map = Thread.getAllStackTraces();
        Set tt = map.keySet();
        Iterator<Thread> ti = tt.iterator();
        try{
            long idFind = Long.parseLong(thrdId);
            out.print("<br> idFind thread |" + idFind + "| <br>");
            boolean found = false;
            while(ti.hasNext() ){
                thrd = ti.next();
                if(thrd.getId() == idFind){
                    out.print("<br> stopping thread " + thrd + " <br>");
                    out.flush();
                    thrd.stop();
                    out.print("<br>stopped " );
                    found = true;
                    break;
                }
            }
            if(!found){
                out.print("<br>not found " );
    
            }
        }catch(Exception e){
            out.println("<br>err " + e + "<br>");
        }
    
    }
    

Output of this was not found. The input param was the tid – pasted in Windows 7 calc, Programmer mode (hex) and then clicked Dec.

UPDATE:

In my test code when I made a JSP that loops infinitely, outputting a char every few 10000s iterations – then did a jstack, got:

"http-0.0.0.0-8181-4" daemon prio=6 tid=0x000000000d4eb000 nid=0x2f58 waiting on condition [0x0000000010fee000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)

...(stack trace)
at org.apache.jsp.t.testing.loop_jsp._jspService(loop_jsp.java
...more stack trace...

I ran jstack a few times and get this entry every time.

But when I run my JSP with thread id = 000000000d4eb000, it cant find it, since the app container names threads uniquely I was able to find the thread and when I print:

out.print("" + cnt + " \"" + thrd.getName() + "\"| id :" + thrd.getId() + "| hex :" +  Long.toHexString(thrd.getId()) + "| <br>");

I get :

93 "http-0.0.0.0-8181-4"| id :1389| hex :56d| 

93 is the thread number in my internal counter in the loop.

So what jstack apparently identifies as finds as 0x000000000d4eb000 internal JVM knows as
1389 hex :56d? Finally changed the JSP to search by name and stop the thread. lucky the thread names are all different. But is this a bug – running Windows, JBoss 4.2, Java 1.6 update 32?

  • 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-06-10T19:32:34+00:00Added an answer on June 10, 2026 at 7:32 pm

    You can only find and stop your own threads. I would try interrupting the thread in case it can stop gracefully.

    Stopping a thread is a bad idea in general as it can leave the application in an inconsistent or unrecoverable state. The only way you can avoid this is to have a very good understand of exactly everything the thread might be doing, in what case its likely that fixing the code so it stops gracefully is simpler and better

    we cant use jconsole in our environment

    jvisualvm is a much better tool in any case. I wouldn’t use jconsole unles syou had to.

    how do I convert (java code would be super) the hex to a java long?

    long idFind = Long.parseLong(thrdId, 16);
    

    could you tell me why this did not work

    Either you didn’t run this from the same process or the thread caught the ThreadDeath error you triggered.

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

Sidebar

Related Questions

I've had a look through existing questions, but I haven't really come across anything
I've had a look around on StackOverlow but haven't been able to find a
I had a look through the documentation on the Wiki, but it seems a
I've had a look around SO and Google but can't find a definite and
I have had a look all over, but it doesn't seem as though my
I've had a look at Stack Overflow question Initialization of a microSD card using
I've had a look around for the answer to this, but I only seem
I got problem with core data, I had a table that exactly look like
I've had a look around but haven't managed to find what I'm looking for.
I had a look around and didn't find what I was exactly looking for.

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.