java - La différence entre Executors.newSingleThreadExecutor().execute(commande et nouveau Thread(command).start;

Mots clés : javamultithreading

meilleur 2 Réponses java - La différence entre Executors.newSingleThreadExecutor().execute(commande et nouveau Thread(command).start;

vote vote

98

public void sendEventSingleThreadExecutor(Event e){   Executor.singleThreadExecutor().execute(()->{//send the event here}) } 
public void sendEventThread(Event e){   Thread(//send the event here).start(); } 
vote vote

86

ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime,  TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler) 

Questions similaires