<commit_before>package com.ironz.binaryprefs.task;

import com.ironz.binaryprefs.exception.ExceptionHandler;

import java.util.Map;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Performs all submitted tasks in one separated thread sequentially.
 */
public final class ScheduledBackgroundTaskExecutor implements TaskExecutor {

    private static final int THREADS_COUNT = 1;
    private static final String THREAD_NAME_PREFIX = "binaryprefs-pool-%s-%s";

    private static final Map<String, ExecutorService> executors = new ConcurrentHashMap<>();
    private static final AtomicInteger threadId = new AtomicInteger();

    private final ExceptionHandler handler;
    private final ExecutorService currentExecutor;

    public ScheduledBackgroundTaskExecutor(final String prefName, final ExceptionHandler handler) {
        this.handler = handler;
        this.currentExecutor = createExecutor(prefName);
    }

    private ExecutorService createExecutor(final String prefName) {
        if (executors.containsKey(prefName)) {
            return executors.get(prefName);
        }
        ThreadFactory factory = createThreadFactory(prefName);
        ExecutorService service = Executors.newFixedThreadPool(THREADS_COUNT, factory);
        executors.put(prefName, service);
        return service;
    }

    private ThreadFactory createThreadFactory(final String prefName) {
        return new ThreadFactory() {
            @Override
            public Thread newThread(Runnable r) {
                return createThread(r, prefName);
            }
        };
    }

    private Thread createThread(final Runnable r, final String prefName) {
        Thread thread = new Thread(r);
        thread.setName(String.format(THREAD_NAME_PREFIX, prefName, threadId.incrementAndGet()));
        thread.setPriority(Thread.MAX_PRIORITY);
        return thread;
    }

    @Override
    public synchronized FutureBarrier submit(final Runnable runnable) {
        Future<?> submit = currentExecutor.submit(runnable);
        return new FutureBarrier(submit, handler);
    }
}<commit_msg>removed synchronized from `submit` task executor method<commit_after>package com.ironz.binaryprefs.task;

import com.ironz.binaryprefs.exception.ExceptionHandler;

import java.util.Map;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Performs all submitted tasks in one separated thread sequentially.
 */
public final class ScheduledBackgroundTaskExecutor implements TaskExecutor {

    private static final int THREADS_COUNT = 1;
    private static final String THREAD_NAME_PREFIX = "binaryprefs-pool-%s-%s";

    private static final Map<String, ExecutorService> executors = new ConcurrentHashMap<>();
    private static final AtomicInteger threadId = new AtomicInteger();

    private final ExceptionHandler handler;
    private final ExecutorService currentExecutor;

    public ScheduledBackgroundTaskExecutor(final String prefName, final ExceptionHandler handler) {
        this.handler = handler;
        this.currentExecutor = createExecutor(prefName);
    }

    private ExecutorService createExecutor(final String prefName) {
        if (executors.containsKey(prefName)) {
            return executors.get(prefName);
        }
        ThreadFactory factory = createThreadFactory(prefName);
        ExecutorService service = Executors.newFixedThreadPool(THREADS_COUNT, factory);
        executors.put(prefName, service);
        return service;
    }

    private ThreadFactory createThreadFactory(final String prefName) {
        return new ThreadFactory() {
            @Override
            public Thread newThread(Runnable r) {
                return createThread(r, prefName);
            }
        };
    }

    private Thread createThread(final Runnable r, final String prefName) {
        Thread thread = new Thread(r);
        thread.setName(String.format(THREAD_NAME_PREFIX, prefName, threadId.incrementAndGet()));
        thread.setPriority(Thread.MAX_PRIORITY);
        return thread;
    }

    @Override
    public FutureBarrier submit(final Runnable runnable) {
        Future<?> submit = currentExecutor.submit(runnable);
        return new FutureBarrier(submit, handler);
    }
}
{'fraction_non_alphanumeric': 0.078348580811635, 'fraction_numerical': 0.0004691531785127844, 'mean_word_length': 3.450939457202505, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1797392', 'n_tokens_mistral': 1087, 'n_tokens_neox': 1066, 'n_words': 283}