1 <p> This method synchronizes on a field in what appears to be an attempt
2 to guard against simultaneous updates to that field. But guarding a field
3 gets a lock on the referenced object, not on the field. This may not
4 provide the mutual exclusion you need, and other threads might
5 be obtaining locks on the referenced objects (for other purposes). An example
6 of this pattern would be:
9 private Long myNtfSeqNbrCounter = new Long(0);
10 private Long getNotificationSequenceNumber() {
12 synchronized(myNtfSeqNbrCounter) {
13 result = new Long(myNtfSeqNbrCounter.longValue() + 1);
14 myNtfSeqNbrCounter = new Long(result.longValue());