/** * Closes the socket and stops the listener thread. * * @throws java.io.IOException if any. */ public void close() throws IOException { boolean interrupted = false; WorkerTask l = listener; if (l != null) { l.terminate(); l.interrupt(); try { l.join(); } catch (InterruptedException ex) { interrupted = true; logger.warn(ex); } } listener = null; if (interrupted) { Thread.currentThread().interrupt(); } }
public synchronized void run() { while ((!stop) && run) { if (task != null) { task.run(); synchronized (ThreadPool.this) { task = null; ThreadPool.this.notify(); } } else { try { wait(); } catch (InterruptedException ex) { run = respawnThreads; break; } } } }
public void close() { stop = true; WorkerTask st = server; if (st != null) { st.terminate(); } }
public void interrupt() { task.interrupt(); thread.interrupt(); } }
public void join() throws InterruptedException { task.join(); thread.join(joinTimeout); }
public synchronized void run() { while ((!stop) && run) { if (task != null) { task.run(); task = null; synchronized (ThreadPool.this) { ThreadPool.this.notify(); } } else { try { wait(); } catch (InterruptedException ex) { run = respawnThreads; break; } } } }
public void close() { stop = true; WorkerTask st = server; if (st != null) { st.terminate(); } }
public void interrupt() { task.interrupt(); thread.interrupt(); } }
public void join() throws InterruptedException { task.join(); thread.join(joinTimeout); }
public void run() { while ((!stop) && run) { if (task != null) { synchronized (this) { task.run(); task = null; } synchronized (ThreadPool.this) { ThreadPool.this.notify(); } } else synchronized (this) { try { if (task == null) { wait(); } } catch (InterruptedException ex) { run = respawnThreads; break; } } } }
public void close() { stop = true; WorkerTask st = server; if (st != null) { st.terminate(); } }
public void interrupt() { task.interrupt(); thread.interrupt(); } }
public void join() throws InterruptedException { task.join(); thread.join(joinTimeout); }
/** * Closes all open sockets and stops the internal server thread that * processes messages. */ public void close() { WorkerTask st = server; if (st != null) { server = null; st.terminate(); st.interrupt(); try { st.join(); } catch (InterruptedException ex) { logger.warn(ex); } closeSockets(sockets); if (socketCleaner != null) { socketCleaner.cancel(); } socketCleaner = null; } }
/** * Starts the listener thread that accepts incoming messages. The thread is * started in daemon mode and thus it will not block application terminated. * Nevertheless, the {@link #close()} method should be called to stop the * listen thread gracefully and free associated ressources. * * @throws java.io.IOException if any. */ public synchronized void listen() throws IOException { if (listener != null) { throw new SocketException("Port already listening"); } listenerThread = new ListenThread(); listener = SNMP4JSettings.getThreadFactory().createWorkerThread( "DefaultUDPTransportMapping_" + getAddress(), listenerThread, true); listener.run(); }
public void terminate() { stop = true; WorkerTask t; if ((t = task) != null) { t.terminate(); } }