• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread ID

 
Ranch Hand
Posts: 74
Netbeans IDE Tomcat Server Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know if this has been asked before,but how should I know what ID a thread has?

there's nothing about it in the K&B book,neither in the javadoc of the getId() method

and yet there are questions that require you to guess the output of this method
 
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you check the API?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't guess it, and I don't think that there are questions which suppose that you can. What you can know for sure is the "name" of the thread, because you can pass it in a constructor.
 
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All you need to know about the thread ID as far as SCJP is concerned is that it's a long, and it is guaranteed to be different for all active threads.

So you'll get questions that say "which of the following outputs are possible", and include outputs of the thread ID. The ID is just there to tell the threads apart. It's the order that they are output that is the point of the question.
 
Mahmoud Hossam
Ranch Hand
Posts: 74
Netbeans IDE Tomcat Server Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Matthew Brown wrote:All you need to know about the thread ID as far as SCJP is concerned is that it's a long, and it is guaranteed to be different for all active threads.

So you'll get questions that say "which of the following outputs are possible", and include outputs of the thread ID. The ID is just there to tell the threads apart. It's the order that they are output that is the point of the question.



thanks a lot for the insight
 
reply
    Bookmark Topic Watch Topic
  • New Topic