1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-02 06:45:59 +01:00

Use volatile instead of synchronized

in LastActivityManager.
This commit is contained in:
Florian Schmaus 2014-04-23 09:43:48 +02:00
parent 0996a44a61
commit 439f4cd291

View file

@ -118,7 +118,7 @@ public class LastActivityManager extends Manager {
return lastActivityManager;
}
private long lastMessageSent;
private volatile long lastMessageSent;
private boolean enabled = false;
/**
@ -197,10 +197,7 @@ public class LastActivityManager extends Manager {
* sent.
*/
private void resetIdleTime() {
long now = System.currentTimeMillis();
synchronized (this) {
lastMessageSent = now;
}
lastMessageSent = System.currentTimeMillis();
}
/**
@ -209,11 +206,8 @@ public class LastActivityManager extends Manager {
* @return the lapsed time between the last message sent and now.
*/
private long getIdleTime() {
long lms;
long lms = lastMessageSent;
long now = System.currentTimeMillis();
synchronized (this) {
lms = lastMessageSent;
}
return ((now - lms) / 1000);
}