Java tutorial
//package com.java2s; //License from project: Apache License public class Main { public static long compute(long timeInNanosecond) { final long start = System.nanoTime(); long seed = start; while (System.nanoTime() - start < timeInNanosecond) { seed = (long) Math.sqrt(3.15); } return seed; // try { // TimeUnit.NANOSECONDS.sleep(timeInNanosecond); // } catch (InterruptedException e) { // e.printStackTrace(); // } // return 0; } }