Show CallbackThread.java syntax highlighted
package persister.network;
import java.io.ObjectInputStream;
import persister.Message;
import persister.distributed.CallbackCommunicator;
public class CallbackThread extends Thread {
CallbackCommunicator comm;
ObjectInputStream in ;
public CallbackThread(ObjectInputStream in, CallbackCommunicator comm){
this.in= in;
this.comm = comm;
this.start();
}
public void run(){
try{
while(true){
Object obj = in.readObject();
try{
Message msg = (Message)obj;
comm.receiveMessage(msg);
}catch(ClassCastException e){
//ignore message but don't close connection
System.out.println("Invalid Class in Stream:" + obj.getClass());
}
}
}catch(Exception e){
// e.printStackTrace();
this.stop();
}
}
}
See more files for this project here