✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
public abstract class SomeClass implements Runnable {
private Object lock = new Object ();
public void lock () {
synchronized (lock) {
try {
lock.wait ();
System.out.print ( "1");
} Catch (InterruptedException e) { }
}
}
public void unlock () {
synchronized (lock) {
lock.notify ();
System.out.print ( "2");
}
}
public static void main (String s []) {
new Thread (new SomeClass () {
public void run () {
lock ();
}
}). Start ();
new Thread (new SomeClass () {
public void run () {
unlock ();
}
}). Start ();
}
}
(Java)