Hey I created this code for timeout in my tcp communication, but after I run thread, I can't change the end time? any ideas?
public class Timer extends Thread{
ThreadLocal<Long> endTime= new ThreadLocal<>() {
@Override
public Long initialValue() {
return System.currentTimeMillis()+1000;
}
};
private Client client;
public void resetTimer(){
endTime.set((System.currentTimeMillis())+1000);
}
Timer(Client client){
this.client=client;
endTime.set(System.currentTimeMillis()+1000);
}
public void run() {
while (true) {
if (endTime.get()<System.currentTimeMillis()) {
client.endTimeout();
return;
}
}
}
}
Well I can, but in the actual if the value stays initial?