Skip to content

Instantly share code, notes, and snippets.

@minisu
Last active August 29, 2015 13:59
Show Gist options
  • Select an option

  • Save minisu/10717629 to your computer and use it in GitHub Desktop.

Select an option

Save minisu/10717629 to your computer and use it in GitHub Desktop.
private Long myNtfSeqNbrCounter = new Long(0);
private Long getNotificationSequenceNumber() {
Long result = null;
synchronized(myNtfSeqNbrCounter) {
result = new Long(myNtfSeqNbrCounter.longValue() + 1);
// ...
myNtfSeqNbrCounter = new Long(result.longValue());
// ...
return result;
}
}
//////////////////////////////////////////////////////
private Long myNtfSeqNbrCounter = new Long(0);
private Long getNotificationSequenceNumber() {
Long result = null;
synchronized(this) {
result = new Long(myNtfSeqNbrCounter.longValue() + 1);
// ...
myNtfSeqNbrCounter = new Long(result.longValue());
// ...
return result;
}
}
//////////////////////////////////////////////////////
private String myNtfSeqNbrLock = "lock";
private Long myNtfSeqNbrCounter = new Long(0);
private Long getNotificationSequenceNumber() {
Long result = null;
synchronized(myNtfSeqNbrLock) {
result = new Long(myNtfSeqNbrCounter.longValue() + 1);
// ...
myNtfSeqNbrCounter = new Long(result.longValue());
// ...
return result;
}
}
//////////////////////////////////////////////////////
private Object myNtfSeqNbrLock = new Object();
private Long myNtfSeqNbrCounter = new Long(0);
private Long getNotificationSequenceNumber() {
Long result = null;
synchronized(myNtfSeqNbrLock) {
result = new Long(myNtfSeqNbrCounter.longValue() + 1);
// ...
myNtfSeqNbrCounter = new Long(result.longValue());
// ...
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment