<commit_before>package io.quarkus.deployment.util;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import org.apache.commons.io.FilenameUtils;
import org.jboss.logging.Logger;

public class FSWatchUtil {

    private static final Logger log = Logger.getLogger(FSWatchUtil.class);

    private final List<ExecutorService> executors = new ArrayList<>();

    private volatile boolean closed = false;

    /**
     * in a loop, checks for modifications in the files
     * 
     * @param watchers list of {@link Watcher}s
     */
    public void observe(Collection<Watcher> watchers,
            long intervalMs) {
        ThreadFactory tf = (Runnable r) -> new Thread(r, "FSWatchUtil");
        ExecutorService executorService = Executors.newSingleThreadExecutor(tf);
        executorService.execute(
                () -> doObserve(watchers, intervalMs));
        executors.add(executorService);<commit_msg>Prevent creation a FSWatchUtil thread if there is nothing to watch Currently, the FSWatchUtil is only used to generate code for avro and grpc. Event when their respective extensions are not present in a project, a Thread for FileSystem watching is created.<commit_after>package io.quarkus.deployment.util;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import org.apache.commons.io.FilenameUtils;
import org.jboss.logging.Logger;

public class FSWatchUtil {

    private static final Logger log = Logger.getLogger(FSWatchUtil.class);

    private final List<ExecutorService> executors = new ArrayList<>();

    private volatile boolean closed = false;

    /**
     * in a loop, checks for modifications in the files
     * 
     * @param watchers list of {@link Watcher}s
     */
    public void observe(Collection<Watcher> watchers,
            long intervalMs) {
        if (watchers.isEmpty()) {
            return;
        }

        ThreadFactory tf = (Runnable r) -> new Thread(r, "FSWatchUtil");
        ExecutorService executorService = Executors.newSingleThreadExecutor(tf);
        executorService.execute(
                () -> doObserve(watchers, intervalMs));
        executors.add(executorService);
{'fraction_non_alphanumeric': 0.09480337078651685, 'fraction_numerical': 0.0, 'mean_word_length': 3.7404326123128118, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2145498', 'n_tokens_mistral': 793, 'n_tokens_neox': 773, 'n_words': 217}