Hey, Malatesh!
Sorry for being too succint!
ThredsLetters.class is a class literal... Just like
5 is an int literal, like
5.0 is a double literal (surprisingly, there is a class named 'Class' in java.lang package).
Therefore you can print the class literal (just like you can print any object... you get what the toString() method returns in the Class class). You can have a Class variable. In fact, I imagine you can do all sorts of things, but I haven't got the time to experiment, as it is not asked for
SCJP
On the second matter,
synchronized(Letters.class) is used when you synchronize a static block of code. You probably know that you can synchronize methods and blocks either static or non-static:
- when you synchronize a non-static method, you simply use "synchronize" keyword to synchronize on the current object
- when you synchronize a non-static block, you have to say what object are you synchronizing on [ ex: synchronize(this) ]
Similarly:
- when you synchronize a static method, you simply use "synchronize" keyword to synchronize on the current class
- when you synchronize a static block, you have to say what class are you synchronizing on [ ex: synchronize(MyClass.class) ]
Hope this time I explained it better!
PS: If I said something stupid (hope I didn't, but.. who knows?), please someone correct me!
PPS: I claim the prize for the most 'synchronize' words in a single post :p