I am trying to figure out how to start and stop a serial interface.
class SerialInterface implements Runnable{
// Stream from file
@Override
public void run(){
try {
startInterface();
} catch (IOException ex) {
Logger.getLogger(SerialInterface.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static void main( String StartStop ){
SerialInterface SerialThread = null;
if ( StartStop.equals("start")){
SerialThread = new SerialInterface();
Thread thread1 = new Thread (SerialThread);
thread1.start();
} else {
SerialThread = null;
}
}
private void startInterface() throws IOException { //START DOING STUFF TO SERIAL PORT }
This does not work. How do I stop a thread which was started?