@Override
    protected void runTask() {
        if (backgroundJobServer.isRunning() && reentrantLock.tryLock()) {
            try {
                LOGGER.trace("Looking for enqueued jobs... ");
                final AmountRequest workPageRequest = workDistributionStrategy.getWorkPageRequest();
                if (workPageRequest.getLimit() > 0) {
                    final List<Job> enqueuedJobs = storageProvider.getJobsToProcess(backgroundJobServer, workPageRequest);
                    enqueuedJobs.forEach(backgroundJobServer::processJob);
                    LOGGER.debug("Found {} enqueued jobs to process.", enqueuedJobs.size());
                }
            } finally {
                reentrantLock.unlock();
            }
        }
    }
@Test
    void taskIsNotDoneConcurrentlyBecauseOfTheReentrantLock() throws InterruptedException {
        when(storageProvider.getJobsToProcess(eq(backgroundJobServer), any())).thenAnswer((invocationOnMock) -> {
            sleep(100);
            return emptyList();
        });

        CountDownLatch countDownLatch = new CountDownLatch(2);
        final Thread thread1 = new Thread(() -> {
            runTask(task);
            countDownLatch.countDown();
        });
        final Thread thread2 = new Thread(() -> {
            runTask(task);
            countDownLatch.countDown();
        });
        thread1.start();
        thread2.start();

        countDownLatch.await();
        verify(storageProvider, times(1)).getJobsToProcess(eq(backgroundJobServer), any());
    }