For this I got the output as :
My Doubt is : when the first Thread 's' has been started in gets the lock on the getTotal synchronized method. Then no other Thread can enter that method. but why the output is showing a mix of both Threads??
But if I run the same codeby implementing Runnable then Then Thread 1 is running after the Thread 0 has been completed.
Yes you are right. I made a mistake by passing same runnable target to both threads.
Here t and t1 are having same Runnable target. If so then we will get Thread1 runs after Thread0 has completed? If we have two threads running on different objects we will get a mix.
Synchronization means only one thread( on single object) can access the method at a time.
how can we create two threads on same object when we are extending a Thread class.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com