private void refreshLocalNodeTasks ( ) { Set < Integer > localNodeTasks = workerData . getLocalNodeTasks ( ) ; if ( localNodeTasks == null || localNodeTasks . equals ( lastLocalNodeTasks ) ) { return ; } LOG . info ( "Old localNodeTasks:" + lastLocalNodeTasks + ", new:" + localNodeTasks ) ; lastLocalNodeTasks = localNodeTasks ; List < Integer > localNodeOutTasks = new ArrayList <> ( ) ; for ( Integer outTask : allTargetTasks ) { if ( localNodeTasks . contains ( outTask ) ) { localNodeOutTasks . add ( outTask ) ; } } if ( ! localNodeOutTasks . isEmpty ( ) ) { this . outTasks = localNodeOutTasks ; } randomrange = new RandomRange ( outTasks . size ( ) ) ; }
Don t need to take care of multiple thread racing condition one thread per task