X-No-Archive
Hello,
I am trying to learn java threads, and to attempt an exercise from my
textbook, hwever I am not sure if any of my proposed solutions are in
the right vein...
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...
I'm not sure if I am even on the right track, and can not find any
example solutions to this problem, so if anyone has any idea I would be
very gratefull
Thanks,
Jason
blmblm@myrealbox.com - 13 Sep 2005 16:03 GMT
>X-No-Archive
>Hello,
[quoted text clipped - 6 lines]
>sensors at each trafficlight, one for arriving and entering, and one
>for exiting..., and cars as threads.
[ snip ]
I notice that you posted essentially the same question in
comp.java.lang.programmer. If you're going to do this (post the
same question in two newsgroups), might I suggest that you crosspost?
As it is now, people who don't read both newsgroups will only see
one set of replies and may duplicate something that has already been
said in the other newsgroup. With crossposting that wouldn't happen.
(I guess this might be a "YMMV", since there are those who frown on
crossposting. But in this kind of situation I think it makes sense.)
| B. L. Massingill
| ObDisclaimer: I don't speak for my employers; they return the favor.