Package java.lang

Examples of java.lang.Thread$Cleanup


      loadProps();
      printProps();
      /* start worker threads */
      for (int i = 0; i < workers; ++i) {
        HttpWorker w = new HttpWorker(parent);
        (new Thread(w, "worker #"+i)).start();
        threads.add(w);
      }
     
      ServerSocket ss = new ServerSocket(port);
      while (running) {
       
        Socket s = ss.accept();
       
        HttpWorker w = null;
        synchronized (threads) {
          if (threads.isEmpty()) {
            HttpWorker ws = new HttpWorker(parent);
            ws.setSocket(s);
            (new Thread(ws, "additional worker")).start();
          } else {
            w = (HttpWorker) threads.get(0);
            threads.remove(0);
            w.setSocket(s);
          }
View Full Code Here


    Document oldDoc = getEditor().getDocument();
    if(oldDoc != null)
        oldDoc.removeUndoableEditListener(undoHandler);
    getEditor().setDocument(createDocument());
    frame.setTitle(file);
    Thread loader = new FileLoader(f, (Document)editor.getDocument());
    loader.start();
      }
  }
View Full Code Here

   
        public void actionPerformed(ActionEvent e) {
      Document oldDoc = getEditor().getDocument();
      if(oldDoc != null) {
    getFrame().setTitle(file.getName());
    Thread saver = new FileSaver(parent,file, editor.getDocument());
    saver.start();       
      }
  }
View Full Code Here

            PrintStream stdout = System.out;
            PrintStream stderr = System.err;
            System.setOut(ps);
            System.setErr(ps);
      RunIJ ij = new RunIJ(ijarg);
      Thread ijThread = new Thread(ij);
      try
      {
        ijThread.start();
        if (timeout < 0)
        {
          ijThread.join();
        }
        else
        {
            ijThread.join(timeout * 60 * 1000);
        }
      }
      catch (Exception e)
      {
        System.out.println("Aiiie! Got some kind of exception " + e);
      }

      // Now make sure a shutdown is complete if necessary
      if (shutdownurl != null)
      {
          String[] sdargs = new String[2];
          sdargs[0] = systemHome;
          sdargs[1] = shutdownurl;
          shutdown.main(sdargs);
      }
      // Reset ij.defaultResourcePackage
      ptmp = System.getProperties();
                        ptmp.put("ij.defaultResourcePackage", "/org/apache/derbyTesting/");
      ptmp.put("usesystem", "");
      System.setProperties(ptmp);
      // Reset System.out and System.err
      System.setOut(stdout);
      System.setErr(stderr);
        }
        else if (testType.equals("java"))
        {
      if (javaPath == null)
              javaPath = "org.apache.derbyTesting.functionTests.tests." + testDirName;
     
            String[] args = new String[2];
            args[0] = "-p";
            args[1] = propString;
            Class[] classArray = new Class[1];
            classArray[0] = args.getClass();
            String testName = javaPath + "." + testBase;
            Class JavaTest = Class.forName(testName);
            PrintStream stdout = System.out;
            PrintStream stderr = System.err;
            System.setOut(ps);
            System.setErr(ps);
            // Get the tests's main method and invoke it
            Method testMain = JavaTest.getMethod("main", classArray);
            Object[] argObj = new Object[1];
            argObj[0] = args;
      RunClass testObject = new RunClass(testMain, argObj);
      Thread testThread = new Thread(testObject);
      try
      {
        testThread.start();
        if (timeout < 0)
        {
          testThread.join();
        }
        else
        {
          testThread.join(timeout * 60 * 1000);
        }
      }
      catch(Exception e)
      {
        System.out.println("Exception upon invoking test..." + e);
View Full Code Here

      mLateWindow = TIME_UNIT.convert(lateWindow, unit);
      mStreamIndex = streamIndex;
     
      // create and start the thread

      Thread t = new Thread(name)
      {
        public void run()
        {
          try
          {
            log.debug("thread started");
           
            boolean isDone = false;
            DelayedItem<IMediaData> delayedItem = null;
           
            // wait for all the other stream threads to wakeup
            synchronized (SelfServicingMediaQueue.this)
            {
              mIsInitialized = true;
              SelfServicingMediaQueue.this.notifyAll();
            }
            // start processing media
           
            while (!isDone)
            {
              // synchronized (SelfServicingMediaQueue.this)
             
              mLock.lock();
              try
              {
                // while not done, and no item, wait for one
               
                while (!mDone && (delayedItem = mQueue.poll()) == null)
                {
                  try
                  {
                    mCondition.await();
                  }
                  catch (InterruptedException e)
                  {
                    // interrupt and return
                    Thread.currentThread().interrupt();
                   
                    return;
                  }
                }
               
                // notify the queue that data extracted
               
                mCondition.signalAll();
               
                // record "atomic" done
               
                isDone = mDone;
              }
              finally
              {
                mLock.unlock();
              }
             
              // if there is an item, dispatch it
              if (null != delayedItem)
              {
                IMediaData item = delayedItem.getItem();
               
                try
                {
                  do
                  {
                    // this is the story of goldilocks testing the the media
                   
                    long now = getMediaTime();
                    long delta = delayedItem.getTimeStamp() - now;
                   
                    // if the media is too new and unripe, goldilocks sleeps
                    // for a bit
                   
                    if (delta >= mEarlyWindow)
                    {
                      //debug("delta: " + delta);
                      try
                      {
                        //sleep(MILLISECONDS.convert(delta - mEarlyWindow, TIME_UNIT));
                        sleep(MILLISECONDS.convert(delta / 3, TIME_UNIT));
                      }
                      catch (InterruptedException e)
                      {
                        // interrupt and return
                        Thread.currentThread().interrupt();
                        return;
                      }
                    }
                    else
                    {
                      // if the media is old and moldy, goldilocks says
                      // "ick" and drops the media on the floor
                     
                      if (delta < -mLateWindow)
                      {
                        debug(
                          "@%5d DROP queue[%2d]: %s[%5d] delta: %d",
                          MILLISECONDS.convert(now, TIME_UNIT),
                          mQueue.size(),
                          (item instanceof IVideoPicture ? "IMAGE"
                            : "sound"), MILLISECONDS.convert(delayedItem
                              .getTimeStamp(), TIME_UNIT), MILLISECONDS.convert(
                                delta, TIME_UNIT));
                      }
                     
                      // if the media is just right, goldilocks dispaches it
                      // for presentiation becuse she's a badass bitch
                     
                      else
                      {
                        dispatch(item, delayedItem.getTimeStamp());
                       
                        // debug("%5d show [%2d]: %s[%5d] delta: %d",
                        // MILLISECONDS.convert(getPresentationTime(), TIME_UNIT),
                        // size(),
                        // (delayedItem.getItem() instanceof BufferedImage
                        // ? "IMAGE"
                        // : "sound"),
                        // MILLISECONDS.convert(delayedItem.getTimeStamp(),
                        // TIME_UNIT),
                        // MILLISECONDS.convert(delta, TIME_UNIT));
                      }
                     
                      // and the moral of the story is don't mess with goldilocks
                     
                      break;
                    }
                  }
                  while (!mDone);
                }
                finally
                {
                  if (item != null)
                    item.delete();
                }
              }
            }
          }
          finally
          {
            // close stats frame
           
            if (null != mStatsFrame)
            {
              mStatsFrame.dispose();
              mStatsFrame = null;
            }
           
            // close frame for this queue
           
            MediaFrame frame = mFrames.get(mStreamIndex);
            if (null != frame)
              frame.dispose();
          }
        }
      };

      t.setPriority(priority);
      t.setDaemon(true);

      synchronized (this)
      {
        t.start();
        try
        {
          while (!mIsInitialized)
            this.wait();
        }
View Full Code Here

    public void start() {

        if(killme == null) {

            killme = new Thread(this);

            killme.start();

        }
View Full Code Here

            PrintStream stdout = System.out;
            PrintStream stderr = System.err;
            System.setOut(ps);
            System.setErr(ps);
      RunIJ ij = new RunIJ(ijarg);
      Thread ijThread = new Thread(ij);
      try
      {
        ijThread.start();
        if (timeout < 0)
        {
          ijThread.join();
        }
        else
        {
            ijThread.join(timeout * 60 * 1000);
        }
      }
      catch (Exception e)
      {
        System.out.println("Aiiie! Got some kind of exception " + e);
      }

      // Now make sure a shutdown is complete if necessary
      if (shutdownurl != null)
      {
          String[] sdargs = new String[2];
          sdargs[0] = systemHome;
          sdargs[1] = shutdownurl;
          shutdown.main(sdargs);
      }
      // Reset ij.defaultResourcePackage
      ptmp = System.getProperties();
                        ptmp.put("ij.defaultResourcePackage", "/org/apache/derbyTesting/");
      ptmp.put("usesystem", "");
      System.setProperties(ptmp);
      // Reset System.out and System.err
      System.setOut(stdout);
      System.setErr(stderr);
        }
        else if (testType.equals("java"))
        {
      if (javaPath == null)
              javaPath = "org.apache.derbyTesting.functionTests.tests." + testDirName;
     
            String[] args = new String[2];
            args[0] = "-p";
            args[1] = propString;
            Class[] classArray = new Class[1];
            classArray[0] = args.getClass();
            String testName = javaPath + "." + testBase;
            Class JavaTest = Class.forName(testName);
            PrintStream stdout = System.out;
            PrintStream stderr = System.err;
            System.setOut(ps);
            System.setErr(ps);
            // Get the tests's main method and invoke it
            Method testMain = JavaTest.getMethod("main", classArray);
            Object[] argObj = new Object[1];
            argObj[0] = args;
      RunClass testObject = new RunClass(testMain, argObj);
      Thread testThread = new Thread(testObject);
      try
      {
        testThread.start();
        if (timeout < 0)
        {
          testThread.join();
        }
        else
        {
          testThread.join(timeout * 60 * 1000);
        }
      }
      catch(Exception e)
      {
        System.out.println("Exception upon invoking test..." + e);
View Full Code Here

  {
    if (thr == null);
    {
      counter.resetRate();

      thr = new Thread(this, "Xmt " + owner.port.getName());

      thr.start();
    }
  }
View Full Code Here

     */
    private void startTransmit() {
  if (this.owner.open && (thr == null)) {
      counter.resetRate();

      thr = new Thread(this, "Xmt " + owner.port.getName());

      thr.start();
  }
    }
View Full Code Here

  {
    if (this.owner.open && (thr == null))
    {
      counter.resetRate();

      thr = new Thread(this, "Xmt " + owner.port.getName());

      thr.start();
    }
  }
View Full Code Here

TOP

Related Classes of java.lang.Thread$Cleanup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.