User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

java_random_hints [2012/08/26 17:20] (current)
hkoller created
Line 1: Line 1:
 +===== Performance =====
 +  * Don't use Vector or HashTable (which are synchronized) in single threaded programs. Use ArrayList or HashMap (unsynchronized) instead and avoid the overhead.
 +  * A recent study shows that java.nio can be faster than the old [[http://​​story/​10/​07/​27/​1925209/​Java-IO-Faster-Than-NIO|Slashdot Article]]
 +===== Concurrency =====
 +Taxonomy of how to achieve good concurrency:​
 +   - Immutable objects are inherently thread-safe
 +   - Prefer high level abstractions:​ java.util.concurrent
 +   - Or resort to low level locking with synchronized blocks and java.util.concurrent.locks
 +   - Rarely use low level primitives: volatile variables or java.util.concurrent.atomic classes (This allows for non-blocking synchonization!)
 +   - Never do deliberate undersynchronization
 +General hints
 +  * Format objects can not be shared amongst threads as they are not thread-safe!
 +===== Finding the right JAR =====
 +Frameworks like JBoss come with a great number of .jar Files on which your application can depend. Often you know which class you need but you dont know in which jar the class hides. To help you find the jar file you need to include in your build path change to the directory where you expect the .jar and use the command (replace ServiceMBeanSupport with the class you are looking for)
 +<code bash>
 +find . -name "​*.jar"​ -exec bash -c "echo {} && jar tvf {} | grep ServiceMBeanSupport " \;
java_random_hints.txt ยท Last modified: 2012/08/26 17:20 by hkoller