示例#1
0
 public void refresh() {
   if (fToUpdate && !update()) {
     if (fContendedMonitor != null) {
       fContendedMonitor.refresh();
     }
     for (int i = 0; i < fOwnedMonitors.length; i++) {
       fOwnedMonitors[i].refresh();
     }
   }
 }
示例#2
0
 public synchronized void setToUpdate() {
   if (!fToUpdate) {
     fToUpdate = true;
     if (fContendedMonitor != null) {
       fContendedMonitor.setToUpdate();
     }
     if (fOwnedMonitors != null) {
       for (int i = 0; i < fOwnedMonitors.length; i++) {
         fOwnedMonitors[i].setToUpdate();
       }
     }
   }
 }
示例#3
0
 /**
  * Update the information for this thread.
  *
  * @return <code>true</code> if the contended monitor or the owned monitors changed.
  */
 private boolean update() {
   boolean changed = false;
   synchronized (this) {
     if (!fToUpdate) {
       return false;
     }
     try {
       // update the contended monitor
       IJavaObject contendedMonitor = fThread.getContendedMonitor();
       if (contendedMonitor == null) {
         changed = fContendedMonitor != null;
         fContendedMonitor = null;
       } else {
         changed =
             fContendedMonitor == null || !contendedMonitor.equals(fContendedMonitor.getMonitor());
         fContendedMonitor = ThreadMonitorManager.getDefault().getJavaMonitor(contendedMonitor);
       }
       // update the owned monitors
       IJavaObject[] ownedMonitors = fThread.getOwnedMonitors();
       if (ownedMonitors == null || ownedMonitors.length == 0) {
         // no owned monitor, not much to do
         changed = fOwnedMonitors != null && fOwnedMonitors.length != 0;
         fOwnedMonitors = new JavaMonitor[0];
       } else {
         JavaMonitor[] tmp = new JavaMonitor[ownedMonitors.length];
         ThreadMonitorManager threadMonitorManager = ThreadMonitorManager.getDefault();
         if (changed || fOwnedMonitors.length != ownedMonitors.length) {
           // if we know it changed, we can just create the new list.
           for (int i = 0; i < ownedMonitors.length; i++) {
             tmp[i] = threadMonitorManager.getJavaMonitor(ownedMonitors[i]);
           }
           changed = true;
         } else {
           // we need to check in the new list contains the same monitors as the
           // previous list
           int sameMonitor = 0;
           for (int i = 0; i < ownedMonitors.length; i++) {
             for (int j = 0; j < fOwnedMonitors.length; j++) {
               if (ownedMonitors[i].equals(fOwnedMonitors[i].getMonitor())) {
                 sameMonitor++;
                 break;
               }
             }
             tmp[i] = threadMonitorManager.getJavaMonitor(ownedMonitors[i]);
           }
           changed = sameMonitor != ownedMonitors.length;
         }
         fOwnedMonitors = tmp;
       }
     } catch (DebugException e) {
       Throwable cause = e.getStatus().getException();
       if (!(cause instanceof IncompatibleThreadStateException)) {
         // IncompatibleThreadStateException are expected from Sun VMs
         // if the thread is not suspended.
         // For all other exceptions, null the values.
         fContendedMonitor = null;
         changed = fOwnedMonitors != null && fOwnedMonitors.length != 0;
         fOwnedMonitors = new JavaMonitor[0];
       }
     } finally {
       fToUpdate = false;
     }
   }
   if (changed) {
     fireChangeEvent(DebugEvent.CONTENT);
   }
   return changed;
 }