quarta-feira, abril 23, 2008

Cliff Click's NonBlocking HashTable

Cliff Click has made available his new brainchild, the NonBlocking HashTable.

He claims that it is faster than java.util.concurrent.ConcurrentHashMap.

Check: http://blogs.azulsystems.com/cliff/2007/04/nonblocking_has.html

http://sourceforge.net/projects/high-scale-lib

DecimalFormat, SimpleDateFormat - Threading Issues

The classes java.text.DecimalFormat and java.text.SimpleDateFormat are very useful, but Sun's implementation is not thread-safe. It means that if you want to have a static instance of any of these classes in your EJB, Servlet or JSP page, you can have sporadic problems with incorrect formatting.
You'll need to use a ThreadLocal, or use a local object.
ThreadLocal sample usage:

private static ThreadLocal defaultCurrencyFormat  = new ThreadLocal() {
protected synchronized Format initialValue() {
return new DecimalFormat ("0.00",
new DecimalFormatSymbols (new Locale ("pt", "BR")));
}
};

...

String s = defaultCurrencyFormat.get().format (123.45);

You'll need to use an additional "get".

quarta-feira, março 22, 2006

Recommended reading for Bouncy Castle users

If you're interested in using the Bouncy Castle JCE Library, you'll need to check this book:
Beginning Cryptography with Java, by David Hook.

You can download the examples of the book, if you just want to have a test suite for Bouncy Castle.