Skip to content

Instantly share code, notes, and snippets.

@lucoram
Created October 26, 2020 18:56
Show Gist options
  • Save lucoram/e35da57469b92e4e99e0d6dcdcd67248 to your computer and use it in GitHub Desktop.
Save lucoram/e35da57469b92e4e99e0d6dcdcd67248 to your computer and use it in GitHub Desktop.
import java.util.Random;
public class Driver {
public static void main(String[] args) throws InterruptedException {
Random r = new Random();
Programme p = new Programme();
long startTime = System.currentTimeMillis();
while (true) {
long currentTime = System.currentTimeMillis();
int newValue = r.nextInt(100);
p.updateValue(newValue);
System.out.println("------------------------");
System.out.println("Time : " + ((currentTime - startTime) / 1000) + "s");
System.out.println("new Value : " + newValue);
System.out.println("prog Value : " + p.getMaxValue());
Thread.sleep(1000);
}
}
}
class Programme {
private int maxValue;
public void updateValue(int newValue) {
maxValue = Math.max(newValue, maxValue);
}
public int getMaxValue() {
return maxValue;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment