void function ( int arg0 ) { boolean loc0 = false ; String loc1 = String . valueOf ( arg0 ) ; synchronized ( busyPorts ) { loc0 = busyPorts . contains ( loc1 ) ; if ( loc0 ) busyPorts . remove ( loc1 ) ; } }
need to invoke the method to remove the assigned port if server socket is closed or the found port is no longer needed . because all assigned ports are kept in a set . another case is when invoker calls the method #isportfree int , port will be kept in the set , so if port is no longer to use , remember to invoke this method . concode_field_sep Random random concode_elem_sep Object[] randomLock concode_elem_sep Set<String> busyPorts concode_elem_sep Logger log concode_field_sep int searchFreePort concode_elem_sep int opensServerSocketFromRangePort concode_elem_sep ServerSocket openServerSocket concode_elem_sep void main concode_elem_sep boolean isPortFree