Please explain what happens with overriding the run method with a synchronzed run method? When you override a method, I know it checks for the paramters. But it would seem that the when you override a non-synchronized method to be synchronized, that the machine would get confused since it was not originally set up to handle locks. Please explain.
public class MyThread implements Runnable {
private
String holdA = "This is ";
private int[] holdB = {1,2,3,4,5,6,7,8,9,10};
public static void main(String args[]) {
MyThread z = new MyThread();
(new
Thread(z)).start();
(new Thread(z)).start();
}
public synchronized void run() {
for(int w = 0;w < 10;w++) {
System.out.println(holdA + holdB[w] + ".");
}
}
}