Is this the same result with cord 2 above?
class Hppp extends Thread {
final static StringBuffer sb1 = new StringBuffer();
final static StringBuffer sb2 = new StringBuffer();
public static void main(String args[]) {
new Thread() {
public void run() {
synchronized(sb1) {
sb1.append("A");
sb2.append("B");
System.out.println(sb1);
System.out.println(sb2);
}
}
}.start();
new Thread() {
public void run() {
synchronized(sb2) {
sb1.append("C");
sb2.append("D");
System.out.println(sb2);
System.out.println(sb1);
}
}
}.start();
}
}
Or will Output non-deterministic because of the chance of dadlock?