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();
}