• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

simple deadlock problem

 
vijay kaushik
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what it mean? don't these two statements have the same meaning
i.e.
currentThread and This statement plz clarify
the difference,
deadlock()
{
Thread.currentThread().setName("MainThread");
Thread t = New Thread (this,"racingThread");
t.start();
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand why the subject line of this message mentions "deadlock" -- the question seems unrelated to this.

Thread.currentThread() returns a Thread object, the currently executing Thread.

"this" refers to the object whose method is being called.

"this" and currentThread() will only return the same thing in the relatively rare circumstance that you've subclassed Thread and the code being executed is in that subclass. If you instead implemented Runnable, or if your Thread's code is calling out to other code in another class, then "this" and "currentThread()" will refer to different objects, of course.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic