Threadproofing the Java code