This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads' name can be the same? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads Watch "Threads New topic

Threads' name can be the same?

Nick Widelec
Ranch Hand

Joined: Feb 28, 2013
Posts: 226

Hi everybody,
Directly from here:
Every thread has a name for identification purposes. More than one thread may have the same name. If a name is not specified when a thread is created, a new name is generated for it.

Do they mean that 2 threads named by the JVM may have the same name after a few numbers? like Thread-0 Thread-1 Thread-2 and then again Thread-0? Or is it referring only to the fact that we can assign manually the same name to different threads?(hope this last one is the reality, otherwise there would not be much sense (at least to me));
Thanks in advance.

Paul Clapham

Joined: Oct 14, 2005
Posts: 19869

It's the latter (i.e. you can call a Thread whatever you like, including giving two or more Threads the same name). In general the JVM will give them unique names but I don't believe the documentation says specifically that will happen, it's just an implementation detail.
I agree. Here's the link:
subject: Threads' name can be the same?
It's not a secret anymore!