1_7_4_01_ thread state .avi Overview
1_7_4_02_ wait wake Case .avi
1_7_4_03_ wait wake Case code for .avi
public class DemoWaitAndNotify {
public static void main(String[] args) {
Object object = new Object();
new Thread() {
@Override
public void run() {
while (true) {
synchronized (object) {
System.out.println("告诉老板要的饺子和数量");
try {
object.wait();
} catch (InterruptedException i) {
i.printStackTrace();
}
System.out.println("包子已经做好了,开吃");
System.out.println("------------------------------------------------------------------->>>>");
}
}
}
}.start();
new Thread() {
@Override
public void run() {
while (true) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
synchronized (object) {
System.out.println("老板5秒后做好包子,告诉消费者做好包子了");
object.notify();
}
}
}
}.start();
}
}
1_7_4_04_Object wait parameterized class and method notif.avi
Inter-thread communication 1_7_4_05_ .avi
Waiting and wake-up mechanism
1_7_4_06_ wait wake-up mechanism outlined .avi
1_7_4_08_ wait wake-up mechanism code that implements _ buns class & package .avi
1_7_4_09_ wait wake-up mechanism code that implements _ food goods class & test .avi
Baozi Pu