problem in multi threads execution

actually i am trying to perform multi threading on two different thread classes. but after executing everytime its showing different output. could anyone tell me why its showing like this:
class MyThread extends Thread{
public void run(){
try{
for (int i = 0; i < 10; i++) {
Thread.sleep(1000);
System.out.println("i"+i);

Re: problem in multi threads execution

Yes. The scheduler determines when each thread will run. In a muti-processor environment, threads may actually run concurrently if there is one thread per processor. But threads are asynchronous entities. Some of that can be controlled with synchronization. But that is to ensure that threads don't interfere with each other, not necessarily to ensure that they are scheduled at the same time. Here is a simple example. Imagine that you gave each of two helpers a bucket and said you needed 20 buckets of water. In this case you really don't care in what order they return with their respective buckets of water. What you do care about is that the task was done in half the time that one helper could do it.