/*
(non-Javadoc)
@see net.ossindex.common.IPackageRequest#run()
345213
@Override
  public Collection<PackageDescriptor> run() throws IOException {
    String data = gson.toJson(packages);
    // Perform the OSS Index query
    String response = client.performPostRequest("package", data);

    // Convert the results to Java objects
    Type listType = new TypeToken<List<PackageDescriptor>>() { }.getType();
    Collection<PackageDescriptor> results = gson.fromJson(response, listType);
    filterResults(results); // This will remove vulnerabilities from packages
    return results;
  }
33093
@Override
    public void run() {
        while (!Thread.currentThread().isInterrupted()) {
            try {
                int count = collectionService.commitAnnotations(ANNOTATION_CHUNK_SIZE, TIMEOUT);

                if (count > 0) {
                    LOGGER.info(MessageFormat.format("Committed {0} annotations.", count));
                    jobCounter.addAndGet(count);
                }
                Thread.sleep(POLL_INTERVAL_MS);
            } catch (InterruptedException ie) {
                LOGGER.info("Execution was interrupted.");
                Thread.currentThread().interrupt();
                break;
            } catch (Throwable ex) {
                LOGGER.info("Error occurred while committing annotations. Reason {}", ex.toString());
            }
        }
        LOGGER.warn(MessageFormat.format("Annotation committer thread interrupted. {} annotations committed by this thread.", jobCounter.get()));
        collectionService.dispose();
        monitorService.dispose();
    }
99671
public void run() {
        while (true) {
            Object obj;
            try {
                obj = messages.take();
                notifySubscribers(obj);
            } catch (InterruptedException e) {
                // restore interrupted status
                Thread.currentThread().interrupt();
            }
        }
    }
490340
@Override
    public void run() {
        JCASecurityContext ctx = bootstrapContext.getJCASecurityContext();
        if (ctx != null)
            ctx.runInInboundSecurityContext(work);
        else
            work.run();
    }
166971
@Override
	public void run()
	{
		try
		{
			String serverHost = InetUtils.resolveAutoInterfaceAddress(settings.getStringProperty(FFMQJMXConsoleSettings.SERVER_HOST, "localhost"));
			int serverPort = settings.getIntProperty(FFMQJMXConsoleSettings.SERVER_PORT, 10003);

			String serviceUrl = "service:jmx:rmi://"+serverHost+"/jndi/rmi://"+serverHost+":"+serverPort+"/jmxconnector-FFMQ-server";
			out.println("JMX Service URL : "+serviceUrl);
			this.jmxServiceURL = new JMXServiceURL(serviceUrl);

			printServerVersion();
			
			boolean interactive = settings.getBooleanProperty(FFMQJMXConsoleSettings.INTERACTIVE, false);
			if (interactive)
				interactiveMode();
			else
			{
				String command = settings.getStringProperty(FFMQJMXConsoleSettings.COMMAND, "help");
				processCommand(command);
			}
		}
		catch (Exception e)
		{
			closeJMXResources();
			handleException(e);
		}
	}
370760
@Override
    public void run() {
        try {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){  
                Tr.debug(tc, "Run WriteListenerRunnable start , current thread -->" + Thread.currentThread().getName());
            }
            // clean up everything on this thread
            WebContainerRequestState reqState = WebContainerRequestState.getInstance(false);
            if (reqState != null) {
                reqState.init();
            }
            // Push the original thread's context onto the current thread, also
            // save off the current thread's context
            _tcm.pushContextData();

            // call onWritePossible
            synchronized (this._out) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){  
                    Tr.debug(tc, "Invoking the onWritePossible first time");
                }
                WebContainerRequestState.getInstance(true).setAttribute("com.ibm.ws.webcontainer.upgrade.WriteAllowedonThisThread", true);
                this._listener.onWritePossible();

            }
        } catch (Exception e) {
            // If any other exception is thrown then call error which will set
            // exception from error which will allow application to write error
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){  
                Tr.debug(tc, "An exception occurred during the onWritePossible : " + e);
            }
            _cb.error(_out.getBufferHelper().get_vc(), e);

        } finally {
            // Revert back to the thread's current context
            _tcm.popContextData();
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){  
                Tr.debug(tc, "Run WriteListenerRunnable done");
            }
        }
    }
1250767
@Override
	public void run() {
		initialize();
		running = true;
		openServerSocket();
		while (this.isRunning()) {
			try {
				Socket sock = this.serverSocket.accept();
				ServerThread thread = threadBuilder.build(sock);
				if(thread != null)
					pool.execute(thread);
			} catch (IOException e) {
				DBP.printerror("Could not accept socket connection!");
				DBP.printException(e);
			}
		}
	}
336879
@Override
    public void run() {
        Collections.sort(files);
        for (int i = files.size() - 1; i >= 0; i--) {
            new File(files.get(i)).delete();
        }
    }
298521
public void run() {
    String hostName = host != null ? host : "localhost";
    ServerTools.print("Starting LanguageTool " + JLanguageTool.VERSION +
            " (build date: " + JLanguageTool.BUILD_DATE + ", " + JLanguageTool.GIT_SHORT_ID + ") server on " + getProtocol() + "://" + hostName + ":" + port  + "...");
    server.start();
    isRunning = true;
    ServerTools.print("Server started");
  }
787928
@Override
	public void run() {
		while (running) {
			try {
				// Read the request
				service.execute(new HttpSession(this, socket.accept()));
			} catch (IOException e) {
				// Ignore mostly.
			}
		}
	}
1043563
@Override
  public void run()
  {
    try {
      runImpl();
    } catch (final Throwable e) {
      // env/0203 vs env/0206
      if (e instanceof DisplayableException)
        log.warning(e.getMessage());
      else
        log.warning(e.toString());
      
      _exception = e;
    } finally {
      notifyComplete();
    }
  }
318476
@Override
	public void run() {
		if (logger.isInfoEnabled()) {
			logger.info(String.format("SelectorThread for Management=%s started.", this.management.getName()));
		}
		while (this.started) {
			try {
				FastList<ChangeRequest> pendingChanges = this.management.getPendingChanges();

				// Process any pending changes
				synchronized (pendingChanges) {
					Iterator<ChangeRequest> changes = pendingChanges.iterator();
					while (changes.hasNext()) {
						ChangeRequest change = changes.next();
						switch (change.getType()) {
						case ChangeRequest.CHANGEOPS:
							pendingChanges.remove(change);
							SelectionKey key = change.getSocketChannel().keyFor(this.selector);
							key.interestOps(change.getOps());
							break;
						case ChangeRequest.REGISTER:
							pendingChanges.remove(change);
							SelectionKey key1 = change.getSocketChannel().register(this.selector, change.getOps());
							key1.attach(change.getAssociation());
							break;
						case ChangeRequest.CONNECT:
							if (!change.getAssociation().isStarted()) {
								// if Association is stopped - remove pending connection requests  
								pendingChanges.remove(change);
							} else {
								if (change.getExecutionTime() <= System.currentTimeMillis()) {
									pendingChanges.remove(change);
									change.getAssociation().initiateConnection();
								}
							}
							break;
						case ChangeRequest.CLOSE:
							pendingChanges.remove(change);
							change.getAssociation().close();
						}
					}// end of while
				}

				// Wait for an event one of the registered channels
				this.selector.select(500);

				// System.out.println("Done selecting " +
				// this.selector.selectedKeys().size());

				// Iterate over the set of keys for which events are available
				Iterator<SelectionKey> selectedKeys = this.selector.selectedKeys().iterator();

				while (selectedKeys.hasNext()) {
					SelectionKey key = selectedKeys.next();
					selectedKeys.remove();

					if (!key.isValid()) {
						continue;
					}

					// Check what event is available and deal with it
					if (key.isConnectable()) {
						this.finishConnection(key);
					} else if (key.isAcceptable()) {
						this.accept(key);
					} else if (key.isReadable()) {
						this.read(key);
					} else if (key.isWritable()) {
						this.write(key);
					}
				}

			} catch (Exception e) {
				logger.error("Error while selecting the ready keys", e);
			}
		}

		try {
			this.selector.close();
		} catch (IOException e) {
			logger.error(String.format("Error while closing Selector for SCTP Management=%s", this.management.getName()));
		}

		if (logger.isInfoEnabled()) {
			logger.info(String.format("SelectorThread for Management=%s stopped.", this.management.getName()));
		}
	}
632734
@Override
  public void run() {
    try {
      InjectionHandler.processEvent(InjectionEvent.DIRECTORY_SCANNER_NOT_STARTED);
      if (!shouldRun) {
        //shutdown has been activated
        LOG.warn("this cycle terminating immediately because 'shouldRun' has been deactivated");
        return;
      }

      Integer[] namespaceIds = datanode.getAllNamespaces();
      for(Integer nsid : namespaceIds) {
        UpgradeManagerDatanode um = 
          datanode.getUpgradeManager(nsid);
        if (um != null && !um.isUpgradeCompleted()) {
          //If distributed upgrades underway, exit and wait for next cycle.
          LOG.warn("this cycle terminating immediately because Distributed Upgrade is in process");
          return; 
        }
      }
      
      //We're are okay to run - do it
      delta.resetDelta();
      delta.startRecordingDelta();
      checkDifferenceAndReconcile();      
      
    } catch (Exception e) {
      //Log and continue - allows Executor to run again next cycle
      LOG.error("Exception during DirectoryScanner execution - will continue next cycle", e);
    } catch (Error er) {
      //Non-recoverable error - re-throw after logging the problem
      LOG.error("System Error during DirectoryScanner execution - permanently terminating periodic scanner", er);
      throw er;
    } finally {
      delta.stopRecordingDelta();
      InjectionHandler.processEvent(InjectionEvent.DIRECTORY_SCANNER_FINISHED);
    }
  }
211649
public void run() {
		if (logger.isDebugEnabled()){
    		logger.debug("run");
    	}
		
		final SipContext sipContext = sipFactoryImpl.getSipApplicationDispatcher().findSipApplication(key.getApplicationName());
		if(sipContext != null) {
			SipManager sipManager = sipContext.getSipManager();
									
			MobicentsSipApplicationSession sipApplicationSession = sipManager.getSipApplicationSession(key, false);
					
			if(sipApplicationSession != null) {				
				ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
				boolean batchStarted = false;
				try {
					if(logger.isDebugEnabled()) {
						logger.debug("Asynchronous work for sip app session " + key + " scheduled to run once the sipappsession lock is available.");
					}
					sipContext.enterSipContext();	
					sipContext.enterSipApp(sipApplicationSession, null, false, true);
					batchStarted = sipContext.enterSipAppHa(true);
					if(logger.isDebugEnabled()) {
						logger.debug("Starting Asynchronous work for sip app session " + key);
					}
					work.doAsynchronousWork(sipApplicationSession);
					if(logger.isDebugEnabled()) {
						logger.debug("Done with Asynchronous work for sip app session " + key);
					}
				} catch(Throwable t) {
					logger.error("An unexpected exception happened in the SipApplicationSessionAsynchronousWork callback on sip application session " + key, t);
				} finally {
					if(logger.isDebugEnabled()) {
						logger.debug("Exiting Asynchronous work for sip app session " + key);
					}
					sipContext.exitSipAppHa(null, null, batchStarted);
					sipContext.exitSipApp(sipApplicationSession, null);
					sipContext.exitSipContext(oldClassLoader);			
				}
			} else {
				if(logger.isDebugEnabled()) {
					logger.debug("SipApplicationSession " + key + " couldn't be found, it may have been already invalidated.");
				}
			}
		}
	}
829339
@Override
    public void run()
    {
        while (true)
        {
            try
            {
                Thread.sleep(120000);
                PeerMonitor.getInstance().startSweep();
            }
            catch (final InterruptedException e)
            {
                PeerMonitor.logger.error(e, e);

            }
        }

    }
1325232
@Override
    public void run() {
        while(true) {
            WatchKey key;
            try {
                key = watcher.take();
            } catch (InterruptedException e) {
                log.warn(e);
                continue;
            }

            List<FileInfo> fileInfos = addOnMap.get(key);
            checkAndProcessFileInfo(key, fileInfos);

            // reset key and remove from set if directory no longer accessible
            boolean valid = key.reset();
            if (!valid) {
                addOnMap.remove(key);

                // all directories are inaccessible
                if (addOnMap.isEmpty()) {
                    break;
                }
            }
        }
    }
628789
@Override
  public void run() {

    while (!this.closed) {
      // Grab the next available message source, if any
      final EventSource<T> nextSource = sources.poll();
      if (null != nextSource) {
        // Grab the next message from that source, if any
        final T message = nextSource.getNext();
        if (null != message) {
          // Add the source to the end of the queue again.
          sources.add(nextSource);
          // Send the message. Note that this may block depending on the underlying EventHandler.
          this.output.onNext(message);
        } else {
          // The message source has returned null as the next message. We drop the message source in that case.
          Logger.getLogger(Pull2Push.class.getName()).log(Level.INFO, "Droping message source {0} from the queue",
              nextSource.toString());
        }
      }
    }
  }