Some reader favorites:
EJB fundamentals and session beans
Create a scrollable virtual desktop in Swing
Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API
INDEXHEAD: Glossary of terms
INDEXHEAD: Tips and cautions
These tips and cautions will help you write better programs and save you from agonizing over why the compiler produces error messages.
Thread's static boolean holdsLock(Object o) method. That method returns a Boolean true value if the thread calling that method holds the lock associated with the object
that o references; otherwise, false returns. For example, if you were to place System.out.println (Thread.holdsLock (ft)); at the end of SynchronizationDemo1's main() method, holdsLock() would return false. False would return because the main thread executing the main() method does not use the synchronization mechanism to acquire any lock. However, if you were to place System.out.println (Thread.holdsLock (ft)); in either of run()'s synchronized (ft) statements, holdsLock() would return true because either the deposit thread or the withdrawal thread had to acquire the lock associated with the
FinTrans object that ft references before that thread could enter its critical code section.
run() method because situations arise where multiple threads need to execute run(). Because those threads attempt to synchronize on the same object, only one thread at a time can execute run(). As a result, each thread must wait for the previous thread to terminate before it can access run().
INDEXHEAD: Homework
Please answer the following two questions and complete the exercise:
run() method. Write a program that demonstrates why you should not synchronize that method.
INDEXHEAD: Answers to last month's homework
Last month, I asked you two questions. My answers appear in red.
Multithreading allows a processor to remain productive because the processor does not need to spend all its time waiting for input/output operations to complete.
join() method calls wait(0) instead of the sleep(long millis) method. Why?
Object's wait() methods cause a thread to lose the monitor's ownership. In contrast, Thread's sleep() methods do not cause a thread to lose monitor ownership. That implies threads retain any held locks when they call the sleep() methods. If join() was coded to call a sleep() method, two threads calling that method might deadlock (because they might hold each other's locks). By having join() call wait(0), Sun has eliminated that deadlock potential.
Free Download - 5 Minute Product Review. When slow equals Off: Manage the complexity of Web applications - Symphoniq
![]()
Free Download - 5 Minute Product Review. Realize the benefits of real user monitoring in less than an hour. - Symphoniq