C
Chris Smith
Luc The Perverse said:Now - I have never done any significant multithreaded Java application. Is
it possible to interrupt sleep directly without killing the thread, or is
there a better function to use? (I know in MFC C++ there were Semaphores
and mutex objects, and you could wait for them to be in a triggered state.)
I don't remember enough of MFC to recall exactly how MFC wrapped the
Windows API here. As far as the API itself, though, the equivalent to
Win32 mutexes and critical sections are synchronized blocks, used in
different ways. The equivalents of events are Object.wait and
Object.notify (as implemented in certain ways, and of course combined
with synchronized blocks as they always are).
Semaphores are slightly more complex and not available directly in the
language, but they can be easily built from the monitor functions above.
Beginning with Java 1.5, the java.util.concurrent package contains an
implementation of semaphores. Also, Java 1.5 contains an implementation
of mutexes (known as locks) that are NOT tied to lexical scope in the
language in the manner that synchronized blocks are.
--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation