Bruce Tate, author of “Bitter Java“, referred to my post on “Implementing Read-Write Locks in Java” in his book to explain the possible performance optimization one can achieve by using read-write locks instead of applying “synchronized” (Java’s mutex). However, it should be noted that blind application of read-write locks (rwlocks) can have its own [...]
ead-write lock allows multiple threads to acquire a read lock provided no other thread currently has a write lock on the same object. A thread can acquire a write lock if no other thread owns either a read lock or a write lock.
Many times you are not able to tell exactly which class will be instantiated, until the runtime. In these situations you want to be able to create an object through some identifier such as the name of the class. This is one of the abilities that Reflection API of Java provides.
It is legal and sometimes necessary to cast a derived class pointer into base class pointer. This is also called upcast but by doing so the type information of the pointer gets lost.
Many times in order to optimize software performance programmers use specific compiler flags that generate code tuned to a given hardware architecture. In fact, at times we’d write tight loops in assembly using processor specific instructions to squeeze that extra bit of performance. The peripheral code in “C” or C++ can [...]