|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 8 of 8
About to do something.
My Thread unable to do something. Reason: Second reason.
Cleaning up
Caution: ThreadDeath is a powerful tool for causing a thread to terminate its execution. However, this tool is dangerous, and is the reason Sun
deprecated the stop() method. When a thread throws a ThreadDeath object, all locked monitors unlock as ThreadDeath propagates up the method-call stack. Objects protected by these monitors become accessible to other threads. If those objects
are in an inconsistent state, a program can experience erratic behavior, a database or file can corrupt, and so on. However,
if you know that the thread is not holding any locks, you can safely throw ThreadDeath.
This article completes my coverage of threads by exploring thread groups, volatility, thread-local variables, timers, and
ThreadDeath. You learned to use thread groups to group related threads, to use volatility to allow threads access to main-memory copies
of shared field variables, to use thread-local variables to give threads their own independently initialized values, to use
timers to schedule the execution of tasks either periodically or for a one-time execution, and to use ThreadDeath to let a thread prematurely exit from its run() method.
Next month I'll show you how to use packages to organize your classes and interfaces.
Read more about Core Java in JavaWorld's Core Java section.