Skip to content

Instantly share code, notes, and snippets.

@AnjaliManhas
Created July 30, 2020 17:08
Show Gist options
  • Save AnjaliManhas/c6c4c060850c5e453c951e68cbf9a4c4 to your computer and use it in GitHub Desktop.
Save AnjaliManhas/c6c4c060850c5e453c951e68cbf9a4c4 to your computer and use it in GitHub Desktop.
assigning a task to ExecutorService using execute() method
package com.wordpress.compilationerrors;
import javax.naming.Context;
import java.lang.Thread;
import java.lang.Runnable;
import java.lang.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
// assigning a task to ExecutorService using execute() method
public class ExecutorServiceExample {
public static void main(String[] args) {
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.execute(new Runnable() {
@Override
public void run() {
System.out.println("ExecutorService");
}
});
executorService.shutdown();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment