Brigola, Kenneth Chu, Carmina Madrid, Claudine Navarro, Vincent Reganit, Annalyn Sta. Maria, Maricone
Brigola, Kenneth Chu, Carmina Madrid, Claudine Navarro, Vincent Reganit, Annalyn Sta. Maria, Maricone
Chu, Carmina
Madrid, Claudine
Navarro, Vincent
Reganit, Annalyn
Sta. Maria, Maricone
What are threads?
There are a few simple guidelines you can follow when writing
synchronized blocks that will go a long way toward helping you
to avoid the risks of deadlock and performance hazards:
Keep blocks short. Synchronized blocks should be short
-- as short as possible while still protecting the integrity of
related data operations. Move thread-invariant preprocessing
and postprocessing out of synchronized blocks.
Don't block. Don't ever call a method that might block,
such as InputStream.read(), inside a synchronized block
or method.
Don't invoke methods on other objects while holding a
lock. This may sound extreme, but it eliminates the most
common source of deadlock.
wait(), notify(), notifyAll() methods
Syntax:
<thread>.setPriority(<priority>);
Priorities:
Thread.MIN_PRIORITY
○ Has integer value 1.
Thread.NORM_PRIORITY
○ Has integer value 5.
Thread.MAX_PRIORITY
○ Has integer value 10.
Thread Groups