In the code you gave, you can safely omit the synchronized keyword and declare the "value" variable volatile. The volatile modifier will ensure that a change made in one
thread is immediately visible to all other threads.
Note two things, however. First, volatile will not work properly for methods that access "value" more than once (e.g. read - modify - write). Second, I'm not convinced that synchronizing at the class A level actually buys you anything, it is quite likely that other classes using A are performing operations that need to be synchronized as a whole. If this is true, either the synchronization needs to be pulled out of A, or the operations performed should be incorporated as methods into A. In both cases a simple volatile modifier won't cut it anymore.
- Peter