What is Java Thread Join method and its purpose? – Clear Example

In java Thread join method is used, so that main or parent thread can wait for its child thread to finish its execution and die. After that only main thread can executes its further statements. For example, In below thread program, main () method in Sample class is the main thread and it is creating … Read more What is Java Thread Join method and its purpose? – Clear Example

Awesome Answer for Extending Thread Class vs Implementing Runnable interface in Java

Very nice and concise answer with examples for technical interview question what difference between Extending Thread class and Implementing Runnable Interface in Java. Before answering the differences lets have a brief note and tips that will help you answer the best. Examples of creating threads in java using extending Thread class and Runnable Interface NOTE: … Read more Awesome Answer for Extending Thread Class vs Implementing Runnable interface in Java

What is thread pool in Java? Explain with a scenario and code.

Answer includes thread pool in java with concept and one simple scenario example and program, where thread pool can be used. Answer: Thread pool is collection of multiple threads that is used to performed large number of tasks simultaneously. Tried to include multiple scenarios for better understating and answering the concept with one scenario is … Read more What is thread pool in Java? Explain with a scenario and code.

What is Synchronization in Java and why it is important?

Answer includes about what is synchronization in java multithreading and when do we use it or why it is important. Synchronized meaning, concept and program example explained with or without synchronization. This concept will help understand why to use thread synchronization in java multithreading. Answer: What is synchronization in java? Synchronization in java multithreading is … Read more What is Synchronization in Java and why it is important?

What is critical section in java multithreading?

Answer: A critical section in java multithreading is a piece of code that access shared resources. Resources can be static variable, any Abstract data types or Data structures e.g. List, queue, stack and vector etc.  And File IO etc. For example, in below class function func has a critical section block i.e. int j = … Read more What is critical section in java multithreading?

Java Thread Interview Questions and Answers | Short – Real

This section contains java multi threading real short interview questions and answers asked in IT industries to freshers and experienced. Generally, this kind of questions are asked in software job interview questions to judge candidate skills over multiple areas in the subject in short span of time. Q-Which method must be implemented by all java … Read more Java Thread Interview Questions and Answers | Short – Real

Difference between process and thread in Java Multithreading?

Answer:Difference between process and thread in java multithreading listed below is applied to all languages i.e. Java, C, C++ and C# etc. Here are 4 major important differences are described. 1)Processes are heavy-weight and threads are light-weight. Heavy –weight: each process shares different virtual address space. Light-weight: each thread shares same virtual space. Means, threads … Read more Difference between process and thread in Java Multithreading?

What is difference between start and run in Java Thread?

Answer includes the difference between start and run Describing the interview question, difference between run and start method in Java multithreading with example. But, also note that this question can also be asked as  below “if start() method eventually call run() method in a thread then why don’t we call run() method directly?” Answer: Thread.start() … Read more What is difference between start and run in Java Thread?

What happens if we don’t override run() method during thread creation using extended thread?

Answer: If we don’t override run() method, compiler will not flash any error and it will execute run() method of Thread class that has empty implemented, So, there will be no output for this thread. Below example will not provide any output   public class Sample extends Thread { public static void main(String[] args) { … Read more What happens if we don’t override run() method during thread creation using extended thread?

What happens if we start a thread twice in java multithreading?

What happens if we start a thread twice is a basic multithreading concepts in java. In fact, we cannot start a thread twice on the same instance of a thread. It is illegal to call start() method of a thread class twice on same instance of a thread. On first call of start() method thread … Read more What happens if we start a thread twice in java multithreading?