Please consider the following simple program culled from a book on
Java :
Class CurrentThreadDemo
{
public static void main(String args[])
{
Thread t = Thread.currentThread();
t.setname("My Thread");
Thread.sleep(1000);
}
}
We see here use of the following 3 methods :
1. Thread.currentThread()
2. t.setname() and
3. Thread.sleep()
Is there are any particular reason why Methods 1 and 3 should be
Thread.something
whereas Method 2 should be t.something ?
What is the underlying concept here ? I'm confused about this.
I have seen another example where the following code has been used :
ob1.t.join();
where ob1 is a reference variable to a thread.
Can anyone explain this syntax and exactly why this syntax is so ?
(Note : I understand the concept of join() - it's just the other
syntax I'm confused about and don't understand.)