/** * Start the pumper. * @since 0.9.19 */ public void startup() { _alive = true; I2PThread pumperThread = new I2PThread(_pumper, "Job Queue Pumper", true); pumperThread.setPriority(Thread.NORM_PRIORITY + 1); pumperThread.start(); }
public I2PThread(Runnable r, String name, boolean isDaemon) { super(r, name); setDaemon(isDaemon); setPriority(NORM_PRIORITY); }
/** * Actually run the connection - listen for I2CP messages and respond. This * is the main driver for this class, though it gets all its meat from the * {@link net.i2p.data.i2cp.I2CPMessageReader I2CPMessageReader} * */ public synchronized void startRunning() throws IOException { if (_dead || _reader != null) throw new IllegalStateException(); _reader = new I2CPMessageReader(new BufferedInputStream(_socket.getInputStream(), BUF_SIZE), createListener()); _writer = new ClientWriterRunner(_context, this); I2PThread t = new I2PThread(_writer); t.setName("I2CP Writer " + __id.incrementAndGet()); t.setDaemon(true); t.start(); _out = new BufferedOutputStream(_socket.getOutputStream()); _reader.startReading(); // TODO need a cleaner for unclaimed items in _messages, but we have no timestamps... }
/** * Creates a new instance of this QueuedMessageReader and spawns a pumper thread. */ public QueuedI2CPMessageReader(I2CPMessageQueue in, I2CPMessageEventListener lsnr) { super(lsnr); this.in = in; _reader = new QueuedI2CPMessageReaderRunner(); _readerThread = new I2PThread(_reader, "I2CP Internal Reader " + __readerId.incrementAndGet(), true); }
_gracefulShutdownDetector.setPriority(Thread.NORM_PRIORITY + 1); _gracefulShutdownDetector.start();
/** * @since 0.9.23 */ public I2PThread(ThreadGroup group, Runnable r, String name) { super(group, r, name); setPriority(NORM_PRIORITY); }
} catch (IllegalStateException ise) {} if (!SystemVersion.isAndroid()) I2PThread.addOOMEventListener(_oomListener);
/** * Run client in a new thread. * * @param clientName can be null * @param args can be null * @param threadGroup can be null * @param cl can be null * @since 0.7.13 */ public static void runClient(String className, String clientName, String args[], RouterContext ctx, Log log, ThreadGroup threadGroup, ClassLoader cl) { if (log.shouldLog(Log.INFO)) log.info("Loading up the client application " + clientName + ": " + className + " " + Arrays.toString(args)); I2PThread t; if (threadGroup != null) t = new I2PThread(threadGroup, new RunApp(className, clientName, args, ctx, log, cl)); else t = new I2PThread(new RunApp(className, clientName, args, ctx, log, cl)); if (clientName == null) clientName = className + " client"; t.setName(clientName); t.setDaemon(true); if (cl != null) t.setContextClassLoader(cl); t.start(); }
public void startup() { for (int i = 0; i < _bufferCount; i++) _emptyBuffers.offer(new AsyncBuffer(_bufferSize)); _isRunning = true; _refillThread = new I2PThread(this, "PRNG"); _refillThread.setDaemon(true); _refillThread.setPriority(Thread.NORM_PRIORITY - 2); _refillThread.start(); }
public I2PThread(String name) { super(name); setPriority(NORM_PRIORITY); }
/** * To be instantiated by the context. * Others should use context.simpleTimer() instead * @deprecated use SimpleTimer2 */ @Deprecated private SimpleTimer(I2PAppContext context, String name) { runn = new SimpleStore(true); _log = context.logManager().getLog(SimpleTimer.class); _events = new TreeMap<Long, TimedEvent>(); _eventTimes = new HashMap<TimedEvent, Long>(256); _readyEvents = new ArrayList<TimedEvent>(4); I2PThread runner = new I2PThread(new SimpleTimerRunner()); runner.setName(name); runner.setDaemon(true); runner.start(); long maxMemory = SystemVersion.getMaxMemory(); int threads = (int) Math.max(MIN_THREADS, Math.min(MAX_THREADS, 1 + (maxMemory / (32*1024*1024)))); for (int i = 1; i <= threads ; i++) { I2PThread executor = new I2PThread(new Executor(context, _log, _readyEvents, runn)); executor.setName(name + "Executor " + i + '/' + threads); executor.setDaemon(true); executor.start(); } context.addShutdownTask(new Shutdown()); }
/** does nothing since we aren't threaded */ public synchronized void startup() { _alive = true; _dispatchThreaded = DEFAULT_DISPATCH_THREADED; String threadedStr = _context.getProperty(PROP_DISPATCH_THREADED); if (threadedStr != null) { _dispatchThreaded = Boolean.parseBoolean(threadedStr); } if (_dispatchThreaded) { _context.statManager().createRateStat("pool.dispatchDataTime", "How long a tunnel dispatch takes", "Tunnels", new long[] { 10*60*1000l, 60*60*1000l, 24*60*60*1000l }); _context.statManager().createRateStat("pool.dispatchGatewayTime", "How long a tunnel gateway dispatch takes", "Tunnels", new long[] { 10*60*1000l, 60*60*1000l, 24*60*60*1000l }); I2PThread data = new I2PThread(new TunnelDataDispatcher(), "Tunnel data dispatcher"); data.setDaemon(true); data.start(); I2PThread gw = new I2PThread(new TunnelGatewayDispatcher(), "Tunnel gateway dispatcher"); gw.setDaemon(true); gw.start(); } }
public I2CPMessageReader(InputStream stream, I2CPMessageEventListener lsnr) { _stream = stream; setListener(lsnr); _reader = new I2CPMessageReaderRunner(); _readerThread = new I2PThread(_reader); _readerThread.setDaemon(true); _readerThread.setName("I2CP Reader " + __readerId.incrementAndGet()); }
public I2PThread(Runnable r, String name) { super(r, name); setPriority(NORM_PRIORITY); }