Loading...

Java Multithreading Interview Questions

Java Multithreading Interview Questions
Master Microservices with Spring Boot and Spring Cloud - https://www.udemy.com/microservices-with-spring-boot-and-spring-cloud/?couponCode=YOUTUBE_DESC
Master Hibernate and JPA with Spring Boot in 100 Steps - https://www.udemy.com/hibernate-jpa-tutorial-for-beginners-in-100-steps/?couponCode=YOUTUBE_DESC
Spring Framework Interview Guide - 200+ Questions & Answers - https://www.udemy.com/spring-interview-questions-and-answers/?couponCode=YOUTUBE_DESC
Master Java Web Services and REST API with Spring Boot - https://www.udemy.com/spring-web-services-tutorial/?couponCode=YOUTUBE_DESC
Learn Spring Boot in 100 Steps - Beginner to Expert - https://www.udemy.com/spring-boot-tutorial-for-beginners/?couponCode=YOUTUBE_DESC
Java Interview Guide : 200+ Interview Questions and Answers - https://www.udemy.com/java-interview-questions-and-answers/?couponCode=YOUTUBE_DESC
Become a FullStackDeveloper and Architect - https://github.com/in28minutes/learn/blob/master/readme.md
Download Presentation and Notes - https://courses.in28minutes.com/p/in28minutes-course-guide
Java, Spring Boot, REST, Microservices Learning Path - https://www.youtube.com/watch?v=jf6doctfxWQ
All Spring Boot Articles - http://www.springboottutorial.com/spring-boot-projects-with-code-examples
The in28Minutes Way - https://github.com/in28minutes/in28minutes-initiatives/tree/master/The-in28Minutes-Way
Troubleshooting Guide - https://github.com/in28minutes/in28minutes-initiatives/tree/master/The-in28Minutes-TroubleshootingGuide-And-FAQ  
Java Multithreading Interview Questions and Answers

Questions Discussed:

185 . What is the need for threads in Java?
186 . How do you create a thread?
187 . How do you create a thread by extending thread class?
188 . How do you create a thread by implementing runnable interface?
189 . How do you run a thread in Java?
190 . What are the different states of a thread?
191 . What is priority of a thread? How do you change the priority of a thread?
192 . What is executorservice?
193 . Can you give an example for executorservice?
194 . Explain different ways of creating executor services .
195 . How do you check whether an executionservice task executed successfully?
196 . What is callable? How do you execute a callable from executionservice?
197 . What is synchronization of threads?
198 . Can you give an example of a synchronized block?
199 . Can a static method be synchronized?
200 . What is the use of join method in threads?
201 . Describe a few other important methods in threads?
202 . What is a deadlock?
203 . What are the important methods in Java for inter-thread communication?
204 . What is the use of wait method?
205 . What is the use of notify method?
206 . What is the use of notifyall method?
207 . Can you write a synchronized program with wait and notify methods?

RRelated Posts

CComments

  • Anirban Roy
    Excellent video
  • Vikrant Dheer
    Where we can find your multithreading & generics exercises code ?
  • Vivek Ingle
    How Below 4 method will work parallel in thread can U please explain

    ThreadExamples Example = new ThreadExamples();
    example.download&StoreBatting();
    example.download&StoreBolling();
    example.download&StoreFielding();
    example.MergingAllAPplication();


    Below way are correct or need to be create different classes for each downloaded method

    package threadDemo;

    public class ThreadExamples extends Thread{


    public void run(){
    System.out.println("hello");
    downloadAndStoreBatting();
    downloadAndStoreBolling();
    downloadAndStoreFielding();

    }

    public void downloadAndStoreBatting(){
    System.out.println("show downloadAndStoreBatting");
    }
    public void downloadAndStoreBolling(){
    System.out.println("show downloadAndStoreBolling");
    }
    public void downloadAndStoreFielding(){
    System.out.println("show downloadAndStoreFielding");
    }
    public void MergingAllAPplication(){
    System.out.println("show MergingAllAPplication");
    }


    public static void main(String[] args) {
    ThreadExamples Example = new ThreadExamples();
    Example.start();
    }

    }
  • phaze
    When will you Indians finally learn to pronounce the english language so people can watch these videos without getting cancer?
  • Alok Yadav
    Tysm
  • Neeraj Arora
    The last example the wait and notify are called by locking on different object.. not a good practice as you may miss a signal !!

    Also in the last example you could have simply used join. Not an amazing example to show wait and notify ...
  • Pankaj Dubey
    The thread stack also contains all local variables for each method being executed (all methods on the call stack). A thread can only access it's own thread stack. Local variables created by a thread are invisible to all other threads than the thread who created it. Even if two threads are executing the exact same code, the two threads will still create the local variables of that code in each their own thread stack. Thus, each thread has its own version of each local variable.

    All local variables of primitive types (boolean, byte, short, char, int, long,float, double) are fully stored on the thread stack and are thus not visible to other threads. One thread may pass a copy of a pritimive variable to another thread, but it cannot share the primitive local variable itself.
  • Pankaj Dubey
    how two thread can override the method argument value,every thread have own stack and method argument and local variable is maintained in the stack, can you please provide example and demonstrate, two thread can overide the local variable and share in between
  • Devendra Vishwakarma
    From where can I get the full document which you are going through in the video?
  • pulpo pulpo
    Where can we donwload a complete pdf or ppt file with all the explanations of each question?
  • Umesh Naik
    One big question why wait and notify methods in object class not in thread class?
  • Ravi Goli
    good job man. nice brief summarisation and good articulation than lot of other multithreading videos, which are either too verbose, or too slow, or too digressing with not-that-straight examples, or not articulated well enough. Thanks a lot!! for the free service.
  • Nirmal Mohanty
    After starting the thread I was checking the state using "test.getState()" & the result is RUNNABLE. So I think thread never have a state called RUNNING
  • Praveen Kumar
    Can u provide this PDF link ?
  • Moksud Ahmed
    Why the Thread that will provide us the bowling statistics is called "battingThread2" ? Shouldn't we call it "bowlingThread"?
  • dhruba rivu
    Very well explained in detail. Where can I get the source code?