Ι have the following custom Runnable:
class RandomSum extends Runnable {
public void run() {
float sum - 0;
for(int i = 0; i<1000000;i++){
sum+=Math.random();
}
}
}
And I want to run it like that:
RandomSum s =new RandomSum();
s.retrieveCallback((sum)->{
System.out.println(sum);
});
Thread thread = new Thread();
thread.start();
But I do not know how I should define the method retrieveCallback in RandomSum that accepts a lambda?
RandomSumclass? Do you want to print the sum after theforloop?