Code for a blogpost
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
643 B

  1. package net.jrtechs;
  2. import java.util.concurrent.ThreadLocalRandom;
  3. import java.util.stream.IntStream;
  4. public class DoMaths<E> extends WorkGenerator<Double>
  5. {
  6. @Override
  7. Work<Double> generateWork(Double param) {
  8. return new Work<Double>() {
  9. @Override
  10. Double runTask()
  11. {
  12. return IntStream.range(0, (int)Math.round(param))
  13. .boxed()
  14. .map(i -> Math.sin(i * ThreadLocalRandom.current().nextDouble()))
  15. .mapToDouble(java.lang.Double::doubleValue)
  16. .sum();
  17. }
  18. };
  19. }
  20. }