Skip to content

Commit afbee04

Browse files
author
Tushar Roy
committed
Making value in circular queue 0 before updating position
1 parent f8adab2 commit afbee04

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎src/com/interview/multithreaded/RealTimeCounter.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public void addEvent(){
6262
}
6363

6464
void incrementPosition(){
65+
//first reset the value to 0 at next counter location.
66+
counter.set((pos + 1)%GRANULARITY, 0);
6567
pos = (pos + 1)%GRANULARITY;
6668
}
6769

0 commit comments

Comments
 (0)