• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

How are thread identified in threadpool

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I would like to know, if I set same name for each thread created in thread pool using Thread.currentThread().setName(). Will it cause any problem?
How are threads recognized in threadpool ? by Name OR id OR ???

Thanking you in advance.
Abra
 
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try it and find out.

(Hint: you need to set the name in the constructor.)
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Abrahim:
How are threads recognized in threadpool ?



I am not sure what do you intend by saying "recognized".
I assume you are talking about the ThreadPool Implementation in the jdk, so, I would answer in terms of ThreadPoolExecutor.
It maintains a HashSet of workers(A runnable implementation) and there is no reference to the Thread created. Workers pull tasks from the work queue and execute them.
There is no managing entity that picks up a thread and instructs to execute a task. So, I dont think anybody needs to recognize any thread as such.

Every thread in the JVM is assigned a unique identifier, so, assigning same name does no harm to the thread execution/management but it will create problems for people debugging the thread dumps.
[ July 23, 2008: Message edited by: Nitesh Kant ]
 
Abrahim Daver
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much for the information
 
Can you really tell me that we aren't dealing with suspicious baked goods? And then there is this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic