Guest User

Untitled

a guest
Apr 26th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. public static final int ACTION_UPDATE_WATCH = 1;
  2.  
  3.  
  4. private void refreshWatch() {
  5. Message msg = Message.obtain(null, MyeBayService.ACTION_UPDATE_WATCH);
  6. msg.replyTo = incoming;
  7. try {
  8. log("Refresh request sent...");
  9. myeBaySrvc.send(msg);
  10. } catch (RemoteException e) {
  11. e.printStackTrace();
  12. }
  13. }
  14.  
  15.  
  16. private class IncomingHandler extends Handler {
  17. @Override
  18. public void handleMessage(final Message msg) {
  19.  
  20. Log.v(TAG, "msg.what : " + msg.what);
  21. final int[] lock = new int[] { 0 };
  22.  
  23.  
  24. executor.execute(new Runnable() {
  25. @Override
  26. public void run() {
  27. Log.v(TAG, "Executor msg.what : " + msg.what);
  28. synchronized (lock) { lock[0]++; lock.notify() }
  29. }
  30. });
  31.  
  32. new Thread(new Runnable() {
  33. @Override
  34. public void run() {
  35. Log.v(TAG, "Thread msg.what : " + msg.what);
  36. synchronized (lock) { lock[0]++; lock.notify() }
  37. }
  38. }).run();
  39. synchronized (lock) { while (lock[0] < 2) lock.wait(); }
  40. Log.v(TAG, "msg.what after: " + msg.what);
  41. }
  42. }
Add Comment
Please, Sign In to add comment