Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getting thread names  RSS feed

 
C hurst
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I'm currently working on a project using JPDA. I have to detect instances where threads are started. This is no problem but i have to determine some way of identifying them uniquely. I was going to use the thread names. However i am having problems getting a handler on the thread that was created. basically in my code i pass an event and detect which type of event this is. If its a threadstartevent i take specific action. however at this point i cannot get a handle on the thread
public VisEvent(Event inEvent)
{
if (inEvent instanceof MethodExitEvent) {
setMethodType(methodExit);
setEventType(methodExit);
locEvent = (LocatableEvent) inEvent;
}else if (inEvent instanceof MethodEntryEvent){
setEventType(methodEntry);
setMethodType(methodEntry);
locEvent = (LocatableEvent)inEvent;
}else if(inEvent instanceof ThreadDeathEvent){
setEventType(threadDeath);
decrementStackCounter();
}else if(inEvent instanceof ClassPrepareEvent){
setClassTyp(classPrepare);
setEventTyp(classPrepare);
classPrepareEvent((ClassPrepareEvent)inEvent);
}else if(inEvent instanceof ClassUnloadEvent){
setEventType(classUnload);
setClassType(classUnload);
}else if(inEvent instanceof ThreadStartEvent){
setEventType(threadStart);
incrementStackCounter();
incrementThreadCount();
StackManager threadStack= new StackManager(stackCounter);
}else{
throw new Error("Unexpected event type");
}

but this is causing some problems. Firstly from my understanding thread names are not unique. Is this the case
 
Carl Berndt
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At my shop we set the threadName during the login process.
Then use Thread.currentThread().getName();
to get it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!