private void releaseWatchers(Map<String, WatchEntity> watchers) {
        while (running) {
            if (AgentUtils.getCurrentTime() - coreThreadUpdateTime > CORE_THREAD_MAX_GAP_TIME_MS) {
                LOGGER.error("core thread not update, maybe it has broken");
                break;
            }
            AgentUtils.silenceSleepInMs(CORE_THREAD_SLEEP_TIME);
        }
        watchers.forEach((taskId, watcher) -> {
            try {
                watcher.getWatchService().close();
            } catch (IOException e) {
                LOGGER.error("close watch service failed taskId {}", e, taskId);
            }
        });
    }
Watch directory, if new valid files are created, create instance correspondingly.
inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/task/logcollection/local/FileTask.java