Original Post

Here's my current code and the output:
[source lang="java"]public class Worker{
public static int id;
public static void print(){
System.out.println("Thread hashcode: " + Integer.toString(id));
}
}
public class Main implements Runnable {
public static void main(String[] arg){
Main m = new Main();
Thread t1 = new Thread(m);
Thread t2 = new Thread(m);
t1.start();
t2.start();
}
public synchronized void run(){
Thread t = Thread.currentThread();
for (int i = 0; i < 20; i++){
Worker.id = t.hashCode();
Worker.print();
}
}
}
//=================OUTPUT===========================
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 15868055
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
Thread hashcode: 26983814
[/source]
The ouput, in other words, are labeled as:
AAAAAABBBBBB
I would like to make it so that it does:
ABABABABABAB
In the past, I would create threads and make them work on things independent of one another, Thread A does X work, Thread B does Y work, Thread C does Z work, and so on. The X, Y, and Z do not conflict each other.
Now that I'm starting out on doing multithreading in the same function, I realized it's a unknown adventure for me. I would like someone to lead the way, and warn me, "It's too dangerous to go alone, take this!".
Would anyone like to help?
EDIT: I'm using Firefox 16 and Internet Explorer 9, both browsers appeared to wonk out the code formatting.