Roberto Grena algorithm implementation in java language using one thread of execution