Hey guys,
I've got an input stream from the keyboard and wanting to know how much time passes between when the user enters something to when the user next enters something. That makes sence?
Ive got a class called Timer
public class Counter implements Runnable {
boolean startTimer = true;
int m;
int s;
public Counter() {
m=0;
s=0;
}
public void run(){
try {
wait();
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
//penguin
public void resetTimer() {
m=0;
s=0;
}
public void startTimer() {
while(startTimer) { try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
if(s==60) {
s=0;
m++;
} else {
s++;
}
System.out.println("TIME : " + m + ":" + s);
}
}
public static void main(String args[]) {
String a;
}
The trouble is this ain't right. I'm not sure how to tell it to wait for first string before excuting. I need to do it with 2 threads ... any pointers?