public void distributeFiles(ListenerSupport<FileDistributionListener> listener, final boolean safe) {
		final FileDistribution fileDistribution = getConsoleComponent(FileDistribution.class);
		final AgentCacheState agentCacheState = fileDistribution.getAgentCacheState();
		final Condition cacheStateCondition = new Condition();
		agentCacheState.addListener(ignored -> {
			synchronized (cacheStateCondition) {
				cacheStateCondition.notifyAll();
			}
		});
		final MutableBoolean safeDist = new MutableBoolean(safe);
		ConsoleProperties consoleComponent = getConsoleComponent(ConsoleProperties.class);
		final File file = consoleComponent.getDistributionDirectory().getFile();
		if (listener != null) {
			listener.apply(fileDistributionListener -> {
				safeDist.setValue(fileDistributionListener.start(file, safe));
			});
		}
		final FileDistributionHandler distributionHandler = fileDistribution.getHandler();
		// When cancel is called.. stop processing.
		int fileCount = 0;
		while (!cancel) {
			try {
				final FileDistributionHandler.Result result = distributionHandler.sendNextFile();
				fileCount++;
				if (result == null) {
					break;
				}
				if (listener != null) {
					listener.apply(fileDistributionListener -> {
						fileDistributionListener.distributed(result.getFileName());
					});
				}

				if (safeDist.isTrue()) {
					// The cache status is updated asynchronously by agent
					// reports. If the listener is registered, this waits for up
					// to five seconds for
					// all agents to indicate that they are up to date.
					checkSafetyWithCacheState(fileDistribution, cacheStateCondition, 1);
				}
			} catch (FileContents.FileContentsException e) {
				throw processException("Error while distribute files for " + getConsolePort());
			}
		}
		if (safeDist.isFalse()) {
			ThreadUtils.sleep(1000);
			checkSafetyWithCacheState(fileDistribution, cacheStateCondition, fileCount);
		}
	}
Distribute files on agents.

@param listener listener
@param safe     safe mode
ngrinder-core/src/main/java/net/grinder/SingleConsole.java