Google Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: In-Person
public class Timer {
private static final ThreadLocal<Integer> context = new ThreadLocal<Integer>();
// it will start the timer
void static start(){
long start = System.currentmillies();
context.set(start);
}
// it will stop and return the duraton
long static stop(){
long end = System.currentmillies();
long start = context.get();
return end-start;
}
}
- JAVA February 10, 2014