package lws;
abstract public class Filter implements Runnable{
protected Pipe input_;
protected Pipe output_;
private boolean is_started_ = false;
public Filter(Pipe input, Pipe output){
input_ = input;
output_ = output;
}
//to start a new thread to do the transform work
public void start(){
if(!is_started_){
is_started_ = true;
Thread thread = new Thread(this);
thread.start();
}
}
//to stop the running thread
public void stop(){
is_started_ = false;
}
//the method of the thread
public void run(){
transform();
}
//method to do the transform work of the current instance of Filter
abstract protected void transform();
}
package lws;
import java.io.PipedReader