Basic Java Optimisation Hints

3. Thread synchonisation is expensive

Multithreading is good to improve user interface reactivity, but...

Acquiring locks to guarantee thread safety is slow

If you intend to make extensive use of Java's threads you probably ought to grab a couple of good textbooks

AWT uses a couple of threads, Java3D uses lots of threads

You don't have to lock everything : identify a minimal model for synchronisation

This one is common sense really: acquiring locks to guarantee thread safety is slow (see tip #2). Concurrent programming is a major subject in it's own right and if you intend to make extensive use of Java's threads you probably ought to grab a couple of good textbooks. Even if you don't create any threads of your own, the Java libraries use their own: AWT uses a couple of threads, Java3D uses lots of threads. You're may not be alone... But remember just because your application has multiple threads doesn't mean you have to lock everything. An important part of designing a concurrent system is to determine what data structures each thread will touch, and so identify a minimal model for synchronisation. Look carefully at the Java class libraries too, especially the data containers (see tip #5) some of which are thread-safe while others are not.