Z
zaebos
X-No-Archive
Hello,
I am teaching myself about java threads and concurrency, and have a
textbook exercise that I am trying to implement, but I am not sure if
my design is even on the right track.
The problem is to model an intersection with trafficlights and 2
sensors at each trafficlight, one for arriving and entering, and one
for exiting..., and cars as threads.
the time the car stays in for, the length of time it takes the lights
to switch colors, and the number of cars must all be definable and easy
to change..
I was consiering having each car as a thread, and sensors and
trafficlights as a monitors, when a sensor detects a car arriving, it
notifies the trafficlight to change, and trafficlight will block or
allow the car thread to run, ie enter or leave...
im not sure if im even on the right track, and cant even find any
example solutions to this problem, so if anyone has any idea I would be
very gratefull
Jason
Hello,
I am teaching myself about java threads and concurrency, and have a
textbook exercise that I am trying to implement, but I am not sure if
my design is even on the right track.
The problem is to model an intersection with trafficlights and 2
sensors at each trafficlight, one for arriving and entering, and one
for exiting..., and cars as threads.
the time the car stays in for, the length of time it takes the lights
to switch colors, and the number of cars must all be definable and easy
to change..
I was consiering having each car as a thread, and sensors and
trafficlights as a monitors, when a sensor detects a car arriving, it
notifies the trafficlight to change, and trafficlight will block or
allow the car thread to run, ie enter or leave...
im not sure if im even on the right track, and cant even find any
example solutions to this problem, so if anyone has any idea I would be
very gratefull
Jason