Tuesday, November 13, 2007

Understanding Object wait()

The general rule of thumb to use the wait statement is as follows. This idiom addresses the issue of both missed notifications and early notifications.

synchronized(synclock) {
while (condition_does_not_hold) {
syncLock.wait();
}
// Perform action appropriate to condition
}
// Perform action that needs to be done outside the synchronized block

When wait is called on an Object's instance ...
The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

Tuesday, November 6, 2007

Double-Checked Locking

Here is a very good article on Double-Checked Locking

I liked the 4th method a lot - On Demand Lazy Initialization. Using simple concepts and achieving solution to complex problem.

"Static classes are not initialized until needed and the initialization is guaranteed to be thread-safe."

Monday, November 5, 2007

Telugu font rendering in Ubuntu Feisty Fawn

Copy and Paste these commands and restart machine or XSession(Ctrl+Alt+Backspace)
  • sudo apt-get install ttf-telugu-fonts ttf-indic-fonts language-pack-te
  • wget http://abhiomkar.googlepages.com/lohit_te.ttf
  • sudo cp lohit_te.ttf /usr/share/fonts/truetype/ttf-telugu-fonts/
  • sudo fc-cache
This information is taken from Abhinay's Blog