// IBreakpointManagerListener
 @Override
 public void breakpointManagerEnablementChanged(boolean enabled) {
   IBreakpoint[] breakpoints = getBreakpointManager().getBreakpoints(target.getModelIdentifier());
   final IDbgpSession[] sessions = getSessions();
   for (int i = 0; i < breakpoints.length; ++i) {
     final IBreakpoint breakpoint = breakpoints[i];
     for (int j = 0; j < sessions.length; ++j) {
       final IDbgpSession session = sessions[j];
       scheduleBackgroundOperation(
           target,
           new Runnable() {
             @Override
             public void run() {
               try {
                 if (breakpoint instanceof IScriptSpawnpoint) {
                   changeSpawnpoint(session, (IScriptSpawnpoint) breakpoint);
                 } else {
                   changeBreakpoint(session, (IScriptBreakpoint) breakpoint);
                 }
               } catch (Exception e) {
                 DLTKDebugPlugin.log(e);
               }
             }
           });
     }
   }
 }
 @Override
 public void breakpointRemoved(final IBreakpoint breakpoint, final IMarkerDelta delta) {
   if (!target.supportsBreakpoint(breakpoint)) {
     return;
   }
   final IDbgpSession[] sessions = getSessions();
   for (int i = 0; i < sessions.length; ++i) {
     final IDbgpSession session = sessions[i];
     scheduleBackgroundOperation(
         target,
         new Runnable() {
           @Override
           public void run() {
             try {
               if (breakpoint instanceof IScriptSpawnpoint) {
                 removeSpawnpoint(session, (IScriptSpawnpoint) breakpoint);
               } else {
                 removeBreakpoint(session, (IScriptBreakpoint) breakpoint);
               }
             } catch (Exception e) {
               DLTKDebugPlugin.log(e);
             }
           }
         });
   }
 }
  public void initializeSession(IDbgpSession session, IProgressMonitor monitor) {
    if (!addSession(session)) {
      return;
    }
    IBreakpoint[] breakpoints = getBreakpointManager().getBreakpoints(target.getModelIdentifier());
    monitor.beginTask(Util.EMPTY_STRING, breakpoints.length);

    for (int i = 0; i < breakpoints.length; i++) {
      try {
        final IBreakpoint breakpoint = breakpoints[i];
        if (breakpoint instanceof IScriptSpawnpoint) {
          addSpawnpoint(session, (IScriptSpawnpoint) breakpoint);
        } else {
          addBreakpoint(session, (IScriptBreakpoint) breakpoint);
        }
      } catch (Exception e) {
        DLTKDebugPlugin.logWarning(
            NLS.bind(Messages.ErrorSetupDeferredBreakpoints, e.getMessage()), e);
        if (DLTKCore.DEBUG) {
          e.printStackTrace();
        }
      }
      monitor.worked(1);
    }
    threadAccepted();
    monitor.done();
  }
  private static void scheduleBackgroundOperation(
      final IScriptDebugTarget target, final Runnable runnable) {
    String name = target.getLaunch().getLaunchConfiguration().getName();

    Job breakpointBackgroundJob =
        new Job(
            "Update target breakpoints: " //$NON-NLS-1$
                + name) {
          @Override
          protected IStatus run(IProgressMonitor monitor) {
            try {
              runnable.run();
            } catch (Exception r) {
              DLTKDebugPlugin.logError(r.getMessage(), r);
            }
            return Status.OK_STATUS;
          }
        };
    breakpointBackgroundJob.setSystem(true);
    breakpointBackgroundJob.schedule();
  }
 /**
  * @see IBreakpointListener#breakpointChanged(IBreakpoint, IMarkerDelta)
  * @param breakpoint
  * @param delta if delta is <code>null</code> then there was a call to
  *     BreakPointManager.fireBreakpointChanged(IBreakpoint breakpoint), so see it as a major
  *     change.
  */
 @Override
 public void breakpointChanged(final IBreakpoint breakpoint, final IMarkerDelta delta) {
   if (!target.supportsBreakpoint(breakpoint)) {
     return;
   }
   if (breakpoint instanceof IScriptSpawnpoint) {
     final int changes =
         delta != null
             ? hasSpawnpointChanges(delta, (IScriptSpawnpoint) breakpoint)
             : MAJOR_CHANGE;
     if (changes != NO_CHANGES) {
       final IDbgpSession[] sessions = getSessions();
       for (int i = 0; i < sessions.length; ++i) {
         final IDbgpSession session = sessions[i];
         scheduleBackgroundOperation(
             target,
             new Runnable() {
               @Override
               public void run() {
                 try {
                   if (changes == MAJOR_CHANGE) {
                     removeSpawnpoint(session, (IScriptSpawnpoint) breakpoint);
                     addSpawnpoint(session, (IScriptSpawnpoint) breakpoint);
                   } else {
                     changeSpawnpoint(session, (IScriptSpawnpoint) breakpoint);
                   }
                 } catch (Exception e) {
                   DLTKDebugPlugin.logError(e.getMessage(), e);
                 }
               }
             });
       }
     }
   } else {
     final IScriptBreakpoint sbp = (IScriptBreakpoint) breakpoint;
     final int changes = delta != null ? hasBreakpointChanges(delta, sbp) : MAJOR_CHANGE;
     if (changes != NO_CHANGES) {
       final IDbgpSession[] sessions = getSessions();
       for (int i = 0; i < sessions.length; ++i) {
         final IDbgpSession session = sessions[i];
         scheduleBackgroundOperation(
             target,
             new Runnable() {
               @Override
               public void run() {
                 try {
                   if (changes == MAJOR_CHANGE) {
                     removeBreakpoint(session, sbp);
                     addBreakpoint(session, sbp);
                   } else {
                     changeBreakpoint(session, sbp);
                   }
                 } catch (Exception e) {
                   DLTKDebugPlugin.logError(e.getMessage(), e);
                 }
               }
             });
       }
     }
   }
 }
 public boolean supportsBreakpoint(IBreakpoint breakpoint) {
   return target.supportsBreakpoint(breakpoint);
 }