1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-29 17:52:06 +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; return lastActivityManager;
} }
private long lastMessageSent; private volatile long lastMessageSent;
private boolean enabled = false; private boolean enabled = false;
/** /**
@ -197,10 +197,7 @@ public class LastActivityManager extends Manager {
* sent. * sent.
*/ */
private void resetIdleTime() { private void resetIdleTime() {
long now = System.currentTimeMillis(); lastMessageSent = System.currentTimeMillis();
synchronized (this) {
lastMessageSent = now;
}
} }
/** /**
@ -209,11 +206,8 @@ public class LastActivityManager extends Manager {
* @return the lapsed time between the last message sent and now. * @return the lapsed time between the last message sent and now.
*/ */
private long getIdleTime() { private long getIdleTime() {
long lms; long lms = lastMessageSent;
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
synchronized (this) {
lms = lastMessageSent;
}
return ((now - lms) / 1000); return ((now - lms) / 1000);
} }