R
R
Rammstein0072021-02-15 12:45:29
Java
Rammstein007, 2021-02-15 12:45:29

Why is the method called twice in the ExecutorService in the run block?

The request to help to make so that run was fulfilled only once.

final ExecutorService executor = Executors.newFixedThreadPool(1);
            executor.execute(new Runnable()
            {
                public void run()
                {
                    try
                    {
                      
                        test();
                    }
                    catch (Exception e)
                    {
                        log.error("Ошибка во время запуска", e);
                    }
                    finally
                    {
                        
                    }
                }
            });
            if (!executor.awaitTermination(10, TimeUnit.SECONDS))
            {
                executor.shutdownNow();
            }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question