Skip to content

Commit

Permalink
correcting the synchronization
Browse files Browse the repository at this point in the history
  • Loading branch information
adroitandroid committed Jun 29, 2017
1 parent 8b50eff commit 9e2a83e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void onServiceConnected(ComponentName name, IBinder service) {
Host candidateHost = null;
long jobId = 0;
while (sendDataQueue.size() > 0) {
synchronized (this) {
synchronized (NearConnectImpl.this) {
if (sendDataQueue.size() > 0) {
candidateData = sendDataQueue.remove(0);
candidateHost = sendDestQueue.remove(0);
Expand Down Expand Up @@ -105,7 +105,7 @@ public void run() {
@Override
public long send(byte[] bytes, Host peer) {
long jobId = System.currentTimeMillis();
synchronized (this) {
synchronized (NearConnectImpl.this) {
sendDataQueue.add(bytes);
sendDestQueue.add(peer);
sendJobQueue.add(jobId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private static void setListener(UdpBroadcastListener listener) {

private void updateListenersTo(UdpBroadcastListener listener) {
mListener = listener;
synchronized (this) {
synchronized (UdpBroadcastListeningHandler.this) {
for (StaleHostHandler hostHandler : mHostHandlerMap.values()) {
hostHandler.setListener(listener);
}
Expand Down Expand Up @@ -199,7 +199,7 @@ public void handleMessage(Message msg) {
StaleHostHandler handler = mHostHandlerMap.get(host);
if (handler == null) {
handler = new StaleHostHandler(host, mHostHandlerMap, mListener);
synchronized (this) {
synchronized (UdpBroadcastListeningHandler.this) {
mHostHandlerMap.put(host, handler);
}
if (mListener != null) {
Expand Down

0 comments on commit 9e2a83e

Please sign in to comment.