hvordan laver man parrallel threads
hvordan kan jeg lave de to klasser nedunder så at de kører i to parrallel threads?class 1
public class ttteer{
private SimpleRead;
public ttteer(){
Read = new SimpleRead(this);
}
public void setData(String s){
//the code here set the text in GUI
}
public static void main(String[] args) throws IOException{
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try{
ttteer application = new ttteer();
application.getJFrame().setVisible(true);
}catch(IOException w){
}
}
});
}
}
class 2
public class SimpleRead {
public SimpleRead(){
//the code here opens the serial port
}
public void serialEvent(SerialPortEvent event){
//here i read the data from the serial port whenever there is a serial port event
}
public void writeToport(){
//here I write to the port
}
}