Good day!
ExecutorService executor = Executors.newFixedThreadPool(n); HashSet<Future<Double>> callableSet = new HashSet<Future<Double>>(n); for(;n>0;n--) { Double middleArgument = step/2.0 + step*(n-1); callableSet.add( executor.submit( new rectangleMethodStep( middleArgument , step) ) ); } In this code, rectangleMethodStep is Callable , which calculates some value. Every time I read from HashSet , I get the same sequence, with a different order. Based on the specifics of this collection, I do not understand why the order always changes?
After all, the order we have is determined by the hash code of the element, then the order must be constant