![]() |
![]() |
|
02158 Concurrent Programming Fall 2024 |
Lab 3: Basic Java Monitors - solution proposal |
Home | Plan | Material |
If we introduce monitor variables counting cars going up and down, the invariant to be maintained is:
! (up > 0 && down > 0)
This is ensured by the entry actions:
< up == 0 -> down++ >
< down == 0 -> up++ >
which are readily implemented using the standard pattern in BasicAlley.java
An extra counter counting upgoing cars in the inner alley may be added. Now cars no. 1 and 2 can enter the alley if only upInner is zero. The result can be found in DoubleAlley.java
No solution provided.
Hans Henrik Løvengreen, Oct 31, 2024 |