Java Topics
HubJava Collections FrameworkCollections Practice ProgramsComparable vs ComparatorGenericsIteratorArrayListLinkedListStackVectorHashMapHashtableLinkedHashMapTreeMapArrayDequeDeque Double-Ended QueuePriorityQueueHashSetLinkedHashSetTreeSetAdapter PatternBuilder PatternFactory PatternMVC PatternObserver PatternSingleton PatternDynamic ProgrammingGraphHashingHeapLinked List DSAQueue DSARecursionSearching AlgorithmsSorting AlgorithmsStack DSATime ComplexityTreesException Handling Best PracticesCustom ExceptionException Hierarchyfinally BlockException Handlingthrow aur throwstry-catchBuffered StreamsByte StreamsCharacter StreamsDeserializationFile ClassJava NIO New I/OSerializationArrays in JavaArray OperationsArray Practice ProgramsArray Interview QuestionsJagged ArrayMulti-Dimensional ArraysOne Dimensional Arraybreak aur continuedo-while Loopfor Loopif-else StatementsNested Loopsswitch-case Statementwhile LoopJava Compilation ProcessJava ki FeaturesPehla Java ProgramHistory of JavaJava EditionsJava Program StructureJDK, JRE aur JVMJava Kya Hai?Immutable StringsString Class in JavaString Interview QuestionsString MethodsString Practice ProgramsStringBufferStringBuilderComments in JavaData Types in JavaIdentifiers in JavaInput & Output in JavaJava KeywordsOperators in JavaType Casting in JavaVariables in JavaJava Coding Interview QuestionsCollections Interview QuestionsCore Java Interview QuestionsJDBC Interview QuestionsMultithreading Interview QuestionsOOPs Interview QuestionsSpring Framework Interview QuestionsJava 8 Date/Time APIDefault aur Static Methods in InterfaceFunctional InterfaceLambda ExpressionMethod ReferenceOptional ClassStream APIBatch ProcessingCallableStatementJDBC ArchitectureJDBC — Java Database ConnectivityJDBC Practice ProjectsMySQL ConnectionPreparedStatementResultSetStatement InterfaceTransaction ManagementCreating ThreadsDaemon ThreadExecutor FrameworkInter-Thread CommunicationMultithreading Practice ProgramsRunnable InterfaceSynchronizationThread ClassMultithreading IntroductionThread Life CycleThread PriorityJava Cheat SheetImportant Formulas & Key ConceptsImportant Java ProgramsJava Quick RevisionAbstract ClassAbstractionAnonymous ClassClass and ObjectConstructorEncapsulationInheritanceInner ClassInterfaceMethod OverloadingMethod OverridingObject ClassObject CloningObject-Oriented Programming OOPPolymorphismstatic Keywordsuper Keywordthis KeywordWrapper ClassesArray Practice ProgramsBasic Java Practice ProgramsCollection Practice ProgramsJDBC Practice ProgramsMultithreading Practice ProgramsOOPs Practice ProgramsPlacement Coding QuestionsString Practice ProgramsBanking SystemChat ApplicationE-Commerce Backend — Spring Boot REST APIEmployee Management SystemLibrary Management SystemSpring Boot Fullstack ProjectStudent Management SystemCookies in ServletExpression Language ELGenericServletHttpServletJavaServer Pages JSPJSP TagsMVC ArchitectureHttpServletRequest & HttpServletResponseServlet IntroductionServlet Life CycleSession TrackingDependency InjectionSpring BeansSpring CoreSpring FrameworkAPI GatewaySpring Cloud Config ServerDocker DeploymentEureka Server — Service DiscoverySpring Boot CRUD ApplicationException Handling in Spring BootJWT AuthenticationREST API in Spring BootSpring SecuritySpring BootSpring Data JPAValidation in Spring Boot
Executor Framework
Last Updated : 26 May, 2026
title: Executor Framework in Java
Multithreading36 words5 headingsExamples included
title: Executor Framework in Java description: Thread pool aur ExecutorService
Manually threads banana costly hai. Executor Framework thread pool manage karta hai.
ExecutorService Types
java exampleWoHoTech
// Fixed thread pool
ExecutorService fixed = Executors.newFixedThreadPool(4);
// Single thread
ExecutorService single = Executors.newSingleThreadExecutor();
// Cached — threads as needed (short-lived tasks)
ExecutorService cached = Executors.newCachedThreadPool();
// Scheduled tasks
ScheduledExecutorService scheduled = Executors.newScheduledThreadPool(2);submit() — Runnable / Callable
java exampleWoHoTech
ExecutorService es = Executors.newFixedThreadPool(3);
// Runnable (no return value)
es.submit(() -> System.out.println("Task by " + Thread.currentThread().getName()));
// Callable (return value)
Future<Integer> future = es.submit(() -> {
Thread.sleep(1000);
return 42;
});
System.out.println("Waiting for result...");
int result = future.get(); // Blocking call
System.out.println("Result: " + result);
es.shutdown();invokeAll() — Multiple tasks
java exampleWoHoTech
List<Callable<String>> tasks = new ArrayList<>();
tasks.add(() -> "Task 1 result");
tasks.add(() -> "Task 2 result");
tasks.add(() -> "Task 3 result");
List<Future<String>> futures = es.invokeAll(tasks);
for (Future<String> f : futures)
System.out.println(f.get());ScheduledExecutorService
java exampleWoHoTech
ScheduledExecutorService ses = Executors.newScheduledThreadPool(1);
// 3 seconds baad ek baar
ses.schedule(() -> System.out.println("One-time task"), 3, TimeUnit.SECONDS);
// 2s delay ke baad, har 1s pe repeat
ses.scheduleAtFixedRate(() -> System.out.println("Repeated"), 2, 1, TimeUnit.SECONDS);Shutdown
java exampleWoHoTech
es.shutdown(); // Naye tasks nahi, existing complete honge
es.shutdownNow(); // Interrupt all running tasks
es.awaitTermination(5, TimeUnit.SECONDS); // Wait for shutdownExam Focus
Revise definitions, diagrams, examples, and short-answer points for Executor Framework.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Java topic.
Search Terms
java, java programming, core java, java master course, java notes, master, course, multithreading
Related Java Topics
Continue learning this concept
MultithreadingCreating Threadstitle: Creating Threads in JavaMultithreadingDaemon Threadtitle: Daemon Thread in JavaMultithreadingInter-Thread Communicationtitle: Inter-Thread CommunicationMultithreadingMultithreading Practice Programstitle: Multithreading ProgramsMultithreadingRunnable Interfacetitle: Runnable Interface in JavaMultithreadingSynchronizationtitle: Synchronization in Java