Beispiel #1
0
 /** Called by ImageJ when the user selects Quit. */
 public void quit() {
   quitMacro = IJ.macroRunning();
   Thread thread = new Thread(this, "Quit");
   thread.setPriority(Thread.NORM_PRIORITY);
   thread.start();
   IJ.wait(10);
 }
 public static void startRDPServer() {
   if (rdpServerStarted) return;
   rdpServerStarted = true;
   rdpServerThread = new Thread(rdpServer, "RDPServer");
   retryThread = new Thread(new RetryThread(), "RDPRetry");
   packetCallbackThread = new Thread(new PacketCallbackThread(), "RDPCallback");
   if (Log.loggingNet) Log.net("static - starting rdpserver thread");
   try {
     selector = Selector.open();
   } catch (Exception e) {
     Log.exception("RDPServer caught exception opening selector", e);
     System.exit(1);
   }
   rdpServerThread.setPriority(rdpServerThread.getPriority() + 2);
   if (Log.loggingDebug)
     Log.debug(
         "RDPServer: starting rdpServerThread with priority " + rdpServerThread.getPriority());
   rdpServerThread.start();
   retryThread.start();
   packetCallbackThread.start();
 }
Beispiel #3
0
  /** Starts the unicast and multicast receiver threads */
  void startThreads() throws Exception {
    if (ucast_receiver == null) {
      // start the listener thread of the ucast_recv_sock
      ucast_receiver = new UcastReceiver();
      ucast_receiver.start();
      if (Trace.trace) {
        Trace.info("UDP.startThreads()", "created unicast receiver thread");
      }
    }

    if (ip_mcast) {
      if (mcast_receiver != null) {
        if (mcast_receiver.isAlive()) {
          if (Trace.trace) {
            Trace.info(
                "UDP.createThreads()",
                "did not create new multicastreceiver thread as existing "
                    + "multicast receiver thread is still running");
          }
        } else {
          mcast_receiver = null; // will be created just below...
        }
      }

      if (mcast_receiver == null) {
        mcast_receiver = new Thread(this, "UDP mcast receiver");
        mcast_receiver.setPriority(Thread.MAX_PRIORITY); // needed ????
        mcast_receiver.setDaemon(true);
        mcast_receiver.start();
      }
    }
    if (use_outgoing_packet_handler) {
      outgoing_packet_handler.start();
    }
    if (use_incoming_packet_handler) {
      incoming_packet_handler.start();
    }
  }
 public void start() {
   Thread me = new Thread(this);
   me.setPriority(Thread.MIN_PRIORITY);
   me.start();
 }
Beispiel #5
0
 /** Called by ImageJ when the user selects Quit. */
 public void quit() {
   Thread thread = new Thread(this, "Quit");
   thread.setPriority(Thread.NORM_PRIORITY);
   thread.start();
   IJ.wait(10);
 }
 /**
  * Changes the priority of the listen thread for this UDP transport mapping. This method has no
  * effect, if called before {@link #listen()} has been called for this transport mapping.
  *
  * @param newPriority the new priority.
  * @see Thread#setPriority(int)
  * @since 1.2.2
  */
 public void setPriority(int newPriority) {
   WorkerTask lt = listener;
   if (lt instanceof Thread) {
     ((Thread) lt).setPriority(newPriority);
   }
 }
  public void run() {
    active = true;
    String s = findcachedir();
    uid = getuid(s);
    try {
      File file = new File(s + "main_file_cache.dat");
      if (file.exists() && file.length() > 0x3200000L) file.delete();
      cache_dat = new RandomAccessFile(s + "main_file_cache.dat", "rw");
      for (int j = 0; j < 5; j++)
        cache_idx[j] = new RandomAccessFile(s + "main_file_cache.idx" + j, "rw");

    } catch (Exception exception) {
      exception.printStackTrace();
    }
    for (int i = threadliveid; threadliveid == i; ) {
      if (socketreq != 0) {
        try {
          socket = new Socket(socketip, socketreq);
        } catch (Exception _ex) {
          socket = null;
        }
        socketreq = 0;
      } else if (threadreq != null) {
        Thread thread = new Thread(threadreq);
        thread.setDaemon(true);
        thread.start();
        thread.setPriority(threadreqpri);
        threadreq = null;
      } else if (dnsreq != null) {
        try {
          dns = InetAddress.getByName(dnsreq).getHostName();
        } catch (Exception _ex) {
          dns = "unknown";
        }
        dnsreq = null;
      } else if (savereq != null) {
        if (savebuf != null)
          try {
            FileOutputStream fileoutputstream = new FileOutputStream(s + savereq);
            fileoutputstream.write(savebuf, 0, savelen);
            fileoutputstream.close();
          } catch (Exception _ex) {
          }
        if (waveplay) {
          String wave = s + savereq;
          waveplay = false;
        }
        if (midiplay) {
          midi = s + savereq;
          midiplay = false;
        }
        savereq = null;
      } else if (urlreq != null) {
        try {
          System.out.println("urlstream");
          urlstream = new DataInputStream((new URL(mainapp.getCodeBase(), urlreq)).openStream());
        } catch (Exception _ex) {
          urlstream = null;
        }
        urlreq = null;
      }
      try {
        Thread.sleep(50L);
      } catch (Exception _ex) {
      }
    }
  }
 public void start() {
   running = true;
   Thread thread = new Thread(this);
   thread.setPriority(Thread.MAX_PRIORITY);
   thread.start();
 }