mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 14:22:05 +01:00
Use volatile instead of synchronized
in LastActivityManager.
This commit is contained in:
parent
0996a44a61
commit
439f4cd291
1 changed files with 3 additions and 9 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue