[Thread[pool-1-thread-2,5,main] - What does this mean?

H

Hugo

I would like to check concurrency issues in java web application; like
all developers I did a System.out.println on the current thread:
[Thread[pool-1-thread-8,5,main]

Can anyone help me understand what the values in the system.out are?

I am assuming that:
1: Is the thread pool number
8: Is the thread number
5: I have no clue.

Are my assumptions correct above?
 
D

Daniel

the third could be method that the thread are running.
your assumptions seems good. but I can't answer with 100% certainty.
 
J

John Maline

Hugo said:
I did a System.out.println on the current thread:
[Thread[pool-1-thread-8,5,main]

Can anyone help me understand what the values in the system.out are?

What you're seeing is the output of Thread.getName(). Set with
Thread.setName() or the Thread constructor.

So it could be anything, depending on what the web app container does.
It's not specified by the Java language. Talk to the developer of the
web app container.
 
J

Joshua Cranmer

Hugo said:
I would like to check concurrency issues in java web application; like
all developers I did a System.out.println on the current thread:
[Thread[pool-1-thread-8,5,main]

Can anyone help me understand what the values in the system.out are?

I'm guessing that it is the following:
Simple class name (e.g., Thread)
pool number (1)
thread number (8)
priority (5, or Thread.DEFAULT_PRIORITY)
thread name (main)
 
L

Logan Shaw

Hugo said:
I would like to check concurrency issues in java web application; like
all developers I did a System.out.println on the current thread:
[Thread[pool-1-thread-8,5,main]

Can anyone help me understand what the values in the system.out are?

I am assuming that:
1: Is the thread pool number
8: Is the thread number
5: I have no clue.

Are my assumptions correct above?

As others have said, I don't think there's any spec about this, so
there's no way to be sure without knowing specific details of the
system you're on.

However, I will say this: when I write a toString() method, I often
include in the output some information which can also be retrieved
by getWhatever() methods. Are there are any getWhatever() methods
on Thread that would possibly return an integer with a value of 5?
It turns out Thread.getId() and Thread.getPriority() both return
integer values. And Thread.getState() returns an enum, which could
map to a small integral value. I would try printing out all of
those alongside your toString() output and seeing if one of them
mysteriously happens to always correspond to what you see between
the first and second comma in the toString() output.

- Logan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top