| Author |
Can a class be synchronized
|
ravisha andar
Ranch Hand
Joined: Feb 25, 2011
Posts: 55
|
|
Hi All,
Can anybody please let me know why a class cant be synchronized ?
Regards,
Ravisha
|
 |
Martin Vajsar
Bartender
Joined: Aug 22, 2010
Posts: 1219
|
|
Well, the first problem I can see is that it is not clear how a synchronized class should behave. It is not defined anywhere. If you try to come up with a definition of your own, you might soon get into some trouble (what about static methods, public fields, public static fields etc.)
Secondly, it might not benefit you much. The most naive interpretation of a "synchronized class" is rather easily doable in Java: just make every non-private method synchronized and every non-final field private. In my experience you usually want more sophisticated design, therefore the real use of this "synchronized class" would be very limited anyway.
|
 |
 |
|
|
subject: Can a class be synchronized
|
|
|