File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes  simple deadlock problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark " simple deadlock problem" Watch " simple deadlock problem" New topic
Author

simple deadlock problem

vijay kaushik
Greenhorn

Joined: Jul 11, 2005
Posts: 3
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

Joined: Jul 08, 2003
Posts: 24057
    
  13

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.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: simple deadlock problem
 
Similar Threads
wait/notify deadlock
deadlock with single thread
wait() and notifyAll() in static methods
Threads
Deadlock