Tg a=new Tg();
a.start();
Tg b=new Tg();
b.start();
Theory says that every object has one lock.
So when you made
Tg a=new Tg();
then a will have one lock say
LockForA.
when you did
Tg b=new Tg();
then again different lock for b say
LockForB.
When you call a.start(), this thread will try to get a's lock means
LockForA.
But when you call b.start, this thread will try to get b's lock not a's lock means
LockForB.
So both thread got the lock for their corresponding object, they will execute the run() method simultaneously.
Now another case.
Tg a=new Tg();
Thread t1=new Thread(a);
t1.start();
Thread t2=new Thread(a);
t2.start();
Here whey you call Tg a=new Tg(); a new lock for object a will be created say
LockForA.
when you call t1.start(); it will try to get the object a's lock that is
LockForA. as Thread t1=new Thread(a);, means t1 is running run() method of object a that is synchronized.
when you call t2.start(); it will again try to get the object a's lock that is
LockForA, that is already acquired by t1 thread, so it will wait for the lock. When t1 thread will execute the object a's run() method, it will release the lock, so t2 thread will get the lock and start executing the run() method of object a.
If you have any doubt ask...