blob: ed59bf9c5c3a7aeda5ee4d71fec957e58f89cb40 [file] [log] [blame]
package org.eclipse.ote.io;
import java.util.concurrent.ArrayBlockingQueue;
import org.eclipse.ote.io.internal.PoisonPill;
public class DatagramChannelWorker {
final static PoisonPill POISON_PILL = new PoisonPill();
private final ArrayBlockingQueue<DatagramChannelData> data;
private final DatagramChannelRunnable runnable;
private final String threadName;
public DatagramChannelWorker(String threadName, DatagramChannelRunnable runnable){
this.runnable = runnable;
this.threadName = threadName;
this.data = new ArrayBlockingQueue<DatagramChannelData>(1000);
runnable.setQueue(data);
}
public void start(){
Thread th = new Thread(runnable);
th.setDaemon(true);
th.setName(threadName);
th.start();
}
public void stop() throws InterruptedException{
submit(POISON_PILL);
}
public void submit(DatagramChannelData datagramChannelData) throws InterruptedException{
data.put(datagramChannelData);
}
}