Patricia Shanahan<pats@acm.org> writes:
Multithreaded code often result in concurrency problems, because
I regard them as very expensive bugs, precisely because intermittent,
timing dependent bugs have an unusually high chance of getting through
testing.
?It is our basic belief that extreme caution is
warranted when designing and building multi-threaded
applications, particularly those which have a GUI
component. Use of threads can be very deceptive. In many
cases they appear to greatly simplify programming by
allowing design in terms of simple autonomous entities
focused on a single task. In fact in some cases they do
simplify design and coding. However, in almost all cases
they also make debugging, testing, and maintenance
vastly more difficult and sometimes impossible. Neither
the training, experience, or actual practices of most
programmers, nor the tools we have to help us, are
designed to cope with the non-determinism. For example,
thorough testing (which is always difficult) becomes
nearly impossible when bugs are timing dependent. This
is particularly true in Java where one program can run
on many different types of machines and OS platforms,
and where each program must work under both preemptive
or non-preemptive scheduling.
As a result of these inherent difficulties, we urge you
to think twice about using threads in cases where they
are not absolutely necessary.?
http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html
are usually unavoidable in server apps.