A quick DEMO for Java's Thread API:
- Using
Executors
for the Thread control. - Create two process that must wait until each other's action was done
mvn exec:java
mvn test
The CarCarer
should wait until the CarStatus
is able to do the assign action.
In simplest condition, the washer and waxer will wait each other as below:
Washing start .... finish!
Waxing start .... finish!
Washing start .... finish!
Waxing start .... finish!
Washing start .... finish!
Waxing start .... finish!
Washing start .... finish!
Waxing start .... finish!
Washing start .... finish!
Waxing start .... finish!
Washing start .... finish!
=== Program Finished ==