|
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
just my 0.02$Thats the initial loop.
Looking at the code with no further context,it seems that the
semaphore you are using is the size of the event queue.
Then, in my view, the code should synchronize on access to theUsing the queue for synchronization would of been another way to go although I'm not necessarily seeing how it's more valid or superior although it might force the problem Greg was talking about where the queue being synchronized here prevents it's concurrent update elsewhere?
semaphore proper, not an object that encloses it.
Like this:
...
while(!stopped) {
synchronized (oevents) {
while(oevents.getSize() > 0) {
oevents.pop();
...
}//while work to do
try {oevents.wait();} catch { ... }
}//exclusive access to semaphore
...
}
Hopefully somebody has something somewhat like this working somewhere. I'll keep that in mind if I run into the book. I wouldn't complain by any means to have another decent source of information.
BTW
I just read William Grosso's "Java RMI" which explains amongst other
things the bug you experienced and has lots of hints on how to design
RMI applications, including the proper use of threads and thread-safe
coding.
| References: | |
| >Re: RMI exceptions (From: Eduard de Jong <email@hidden>) |
| Home | Archives | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2011 Apple Inc. All rights reserved.