diff options
author | Ivan Muratov <binakot@gmail.com> | 2017-11-03 15:10:45 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-03 15:10:45 +0300 |
commit | 4e07d664cac49fcbb47376471ef9f4d770293ba9 (patch) | |
tree | 7eaa0886dcb6e44cf4d4aa549abbbaca6533f654 /src/org/traccar/database | |
parent | 74cea90707321c775c11e9cfb91269f63ab4476f (diff) | |
parent | c62dd84c7ad4061c0c6d8a521c63857ccde461ba (diff) | |
download | traccar-server-4e07d664cac49fcbb47376471ef9f4d770293ba9.tar.gz traccar-server-4e07d664cac49fcbb47376471ef9f4d770293ba9.tar.bz2 traccar-server-4e07d664cac49fcbb47376471ef9f4d770293ba9.zip |
Merge branch 'master' into master
Diffstat (limited to 'src/org/traccar/database')
-rw-r--r-- | src/org/traccar/database/StatisticsManager.java | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/org/traccar/database/StatisticsManager.java b/src/org/traccar/database/StatisticsManager.java index 06a3e7b35..9a3ff06bd 100644 --- a/src/org/traccar/database/StatisticsManager.java +++ b/src/org/traccar/database/StatisticsManager.java @@ -27,12 +27,13 @@ import java.util.Calendar; import java.util.Date; import java.util.HashSet; import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; public class StatisticsManager { private static final int SPLIT_MODE = Calendar.DAY_OF_MONTH; - private int lastUpdate = Calendar.getInstance().get(SPLIT_MODE); + private AtomicInteger lastUpdate = new AtomicInteger(Calendar.getInstance().get(SPLIT_MODE)); private Set<Long> users = new HashSet<>(); private Set<Long> devices = new HashSet<>(); @@ -47,7 +48,7 @@ public class StatisticsManager { private void checkSplit() { int currentUpdate = Calendar.getInstance().get(SPLIT_MODE); - if (lastUpdate != currentUpdate) { + if (lastUpdate.getAndSet(currentUpdate) != currentUpdate) { Statistics statistics = new Statistics(); statistics.setCaptureTime(new Date()); statistics.setActiveUsers(users.size()); @@ -96,7 +97,6 @@ public class StatisticsManager { smsSent = 0; geocoderRequests = 0; geolocationRequests = 0; - lastUpdate = currentUpdate; } } |