Java Multithreading Interview Questions and Answers || Daemon Thread in java || Part 2 (Live Demo)
In this video of code decode, you will learn Multithreading Interview Questions and Answers in Java which is important in Java Interview Questions and Answers
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
openinapp.co/u...
Course Description Video :
yt.openinapp.c...
Multi threading Interview questions part 1
• Most Asked Multithread...
Q) Difference between t.start() and t.run()
In the case of t.start() a new Thread will be created which is responsible for the execution of run() method.
But in the case of t.run() no new Thread will be created and run() method will be executed just like a normal method by the main Thread.
In the above program if we are replacing t.start() with t.run() the following is the output. Entire output produced by only main Thread. So Its sequential output always. First child then main / parent
Q) How to make a user thread to a Daemon thread
make a user thread to Daemon by using setDaemon() method of thread class.
This method is used for making a user thread to Daemon thread or vice versa. For example if I have a user thread t then t.setDaemon(true) would make it Daemon thread. On the other hand if I have a Daemon thread td then by calling td.setDaemon(false) would make it normal thread(user thread/non-daemon thread).
public boolean isDaemon(): This method is used for checking the status of a thread. It returns true if the thread is Daemon else it returns false.
setDaemon() method can only be called before starting the thread. This method would throw IllegalThreadStateException if you call this method after Thread.start() method. (refer the example)
The main difference between Daemon thread and user threads is that the JVM does not wait for Daemon thread before exiting while it waits for user threads, it does not exit until unless all the user threads finish their execution.
Q) What are the tasks of start method
Register the Thread with thread scheduler. So you just tell what a child thread should do, when and how it will be scheduled will be handled by scheduler.
Call run method.
Q) What if we don’t override Run method?
Thread class Run method will be called and we won’t get any output.
It’s basically useless as you are saying, please create a thread for me and that thread will do nothing for us. So why did u create it ?
Q) Can we overload run method during multi threading?
How do we overload?
May be by passing parameters?
Yes you can but start () will call no arg run () only.
Q) Can we override start method of thread in multi threaded environment?
If you override start () in your custom class then no initializations will be done by thread class for you.
Q) What is Multi threading & how is it diff from multi tasking asked In java interview question and Answers
Multithreading is a specialized form of multitasking.
Process-based multitasking is executing several tasks simultaneously where each task is a separate independent process is Process-based multitasking .
For example, process based multitasking enables you to run the Java IDE at the same time that you are using a text editor or visiting a web site using chrome.
Thread-based multitasking is executing several tasks simultaneously where each task is a separate independent part of the same program (called Thread).
For instance,JUnit uses threads to run test cases in parallel. As an application, you can have computer games. You see objects in games like cars, motor bikes etc. They are just threads that run in the game application.
Thus, process-based multitasking deals with the “big picture,” and thread-based multitasking handles the details
----------------------------------------------------------------------------------------------------------------------------------------
Most Asked Core Java Interview Questions and Answers : • Core Java frequently a...
Advance Java Interview Questions and Answers : • Advance Java Interview...
Java 8 Interview Questions and Answers : • Java 8 Interview Quest...
Hibernate Interview Questions and Answers : • Hibernate Interview Qu...
Spring Boot Interview Questions and Answers : • Advance Java Interview...
Angular Playlist : • Angular Course Introdu...
GIT : • GIT
-------------------------------------------------------------------------------------------------------------------------------------
Subscriber and Follow Code Decode
Subscriber Code Decode : www.youtube.co...
Linkedin : / codedecodeyoutube
Instagram : / codedecode25
#javainterviewquestions #multithreadinginterviewquestions #codedecode
Пікірлер: 173
Hey guys, as per the request we have tried to reduce the pace. if it's fine just let us know else from next video shall we continue with the existing (a bit faster) pace ?
@shivamrai2889
2 жыл бұрын
Hello ma'am , Can you cover threadpool ?
@sagarmane3281
Жыл бұрын
please cover Executor framework also
@Chaloobolo
Жыл бұрын
Hey
@Chaloobolo
Жыл бұрын
You haven't covered executor service methods , Race conditions and Multithreading concepts like isAlive,Startprocess,MaxProcess ,Pool Window and all . These questions you have covered they will ask from. freshers only not experieneced candidates.
@ashwinibarge9234
Жыл бұрын
Please make video on Executor framework.
I really like it how you give the transcript as description. It saves a lot of time and helps in quick glance . I sincerely appreciate all the efforts and keep up the good job
Great explanations most of the questions that you have covered are repeated in majority of the interviews. One question i came across. Find if a number is odd or even or prime using three threads ,and the result should maintain the natural order
@CodeDecode
3 жыл бұрын
Very nice question Avinash, we will cover it for sure 👍👍
@rushikeshgodase8498
8 ай бұрын
printing odd or even using two threads i know. But how can we print odd or even or prime using three threads??
Waiting for part 3! Please upload if possible! Thanks for your contribution.
Please continue with part 3 as well. Your videos are really helpful in understanding these concepts. I've #subscribed the channel and eagerly waiting for upcoming part.☺️
@CodeDecode
3 жыл бұрын
sure amogh videos are lined up it will get uploaded in couple of weeks
@jaiganeshshan5182
2 жыл бұрын
@@CodeDecode Link for Part3 pls
@nikhilmhatre823
Жыл бұрын
@@CodeDecode Where is 3rd part?
@tanugupta8703
Жыл бұрын
@@CodeDecode where is the 3rd video
Ma'am kindly continue the third part as well as add Exector, fork join as well
@CodeDecode
3 жыл бұрын
Sure Saumil, we will include join and Executor in next video. 👍👍
@vaibhavkalgude9316
3 жыл бұрын
Also please add the concept of synchronization, concurrency
@gauravjaiswal7923
2 жыл бұрын
@@CodeDecode Thanks a lot for the video, Please make video on executor.
@pankajsharma31
2 жыл бұрын
Waiting for more video on threading including Project level usage
@madhanmmm6383
2 жыл бұрын
Please continue with the 3rd part
This channel deserve more subscribers . Great content and explanation Thank you ma'am
@CodeDecode
3 жыл бұрын
This means a lot 🙂🙂👍👍. Thanks Santhosh
I'm really impressed your explanation please make more videos to continue this multithreding concepts , I'm watching all the other videos as well because good explanation
@CodeDecode
2 жыл бұрын
Thanks Anil 🙂👍
Please continue with the video of remaining topics. Content is very help full.
@CodeDecode
2 жыл бұрын
Thanks Madhan 🙂👍
Thanks for these kind of content.. they are really helpful.. i really appreciate your hardwork...
@CodeDecode
3 жыл бұрын
Thanks Entium 👍👍👍
Thanks madam.. I understood about threads now.. please continue it
@CodeDecode
3 жыл бұрын
sure we will continue on this ....
Wonderful, very good explanation. Please try to group all of them by providing links to the previous videos. This will help users to connect previous sessions....
@CodeDecode
3 жыл бұрын
Thank you, We will create the separate playlist for that.....
need next part as well...pls do make video on other methods as well Madam... Thanks in advance
@CodeDecode
3 жыл бұрын
Sure Nikita👍👍
Madam kindly continue third part as well, this is very knowledgeable. thank you
@CodeDecode
3 жыл бұрын
Sure Suresh 👍👍
Next video please for multithreading. It's very good set of questions. Please include interview questions for executor framework as well.
@CodeDecode
3 жыл бұрын
That we will cover in next part for sure Rajesh 👍👍
@syedr16
Жыл бұрын
Yes..even i wanted the video on executor service and other concepts like life cycle of a thread
Please continue with next part and explain all main changes introduced in Java8 also. Please include Executors framework as well.
@CodeDecode
3 жыл бұрын
Sure Venkata 👍👍
is there part 3 ?
Really appreciate ur work 👍👍👍..this could be the best explanation on multithreaded concept in a simple yet crispy way..pls cover all the multithreaded concepts like..deadlock nd concurrency etc..
@CodeDecode
3 жыл бұрын
Sure Sandesh. We will cover them soon 👍👍
Thank You for awesome explanation....Please upload next video....
@CodeDecode
3 жыл бұрын
Sure 👍👍
hi Ur videos are excellent .we can crack most of the interviews be referring all Ur playlist . plz cover executers in multithreading also .
@CodeDecode
10 ай бұрын
Thanks a lot lathasree ❤️❤️😊
Hi You have explained it very well and its really helpful.
@CodeDecode
3 жыл бұрын
Thanks karthik 👍👍
Great content!! Please have more videos on threads, life cycle, join, thread executor, future, etc
@CodeDecode
2 жыл бұрын
Thanks Aashish. Sure we will put more such videos 🙂🙂
Nice Videos till now watched all videos of Interview Questions playlist, please collect the more interview questions for java,spring and keep post regularly. we want more............ interview questions😋. subscribed waiting for the videos.
@CodeDecode
3 жыл бұрын
Sure Chiluka, will collect more and will upload soon 👍👍
Please add 3rd Part of this video. Much needed
@CodeDecode
2 жыл бұрын
Sure Manish 🙂👍
Yes , we want code decode
@CodeDecode
2 жыл бұрын
😇
great video .. we definitely need 3rd part .
@CodeDecode
2 жыл бұрын
Sure Ayush 👍👍
please create the next video. It was a simple and great explanation.
@CodeDecode
2 жыл бұрын
Sure Thanks 🙂👍
please cover the rest of the topics from multi-threading..
@CodeDecode
Ай бұрын
Sure, we will cover it soon
Wonderful, Very good explanation..can you please continue with concepts of multithreading and make another video on it
@CodeDecode
3 жыл бұрын
Sure we will do that👍👍
Thank you so much ....your efforts are much appreciated!!!! Could you please create some other videos covering advanced concepts on this like inter thread communication, Executor framework please.
@CodeDecode
2 жыл бұрын
Thanks. Sure Yash! We will do that soon 👍🙂
@codedecode thank you so much ma'am for such great efforts and creating such useful videos and making learning java concepts easy. Could you please make next videos on multithreading? In many interviews I was asked about thread life cycle, thread pool, thread executor framework. Thank you in advance.
really helpful thank you very much
@CodeDecode
Жыл бұрын
You're welcome
Please upload part 3 with executors service and forked join pool.
Thanks
@CodeDecode
3 ай бұрын
😊👍
This couldn't be any better..Great
@CodeDecode
3 жыл бұрын
Thanks Rishika...
Please make another video which will cover rest of the questions. Also please include inter thread communication questions. 🙏
@CodeDecode
2 жыл бұрын
Sure Gauri we will do that 👍🙂
Hi, Appreciate your content, its very helpful. Please also cover some more advance concepts like concurrency, Parallelism, Read / Write Locks, Deadlock Prevention etc.
@CodeDecode
3 жыл бұрын
Sure Vishal. We were just trying to clear basic concepts with these videos. From next video onwards, we will pick higher level questions
Mam please next continuation of this video
@CodeDecode
2 жыл бұрын
Sure we wil continue this series soon 👍🙂
Please upload third part of multithreading explaining all the remaining topics!!!
Ma'am kindly continue this series
@CodeDecode
3 жыл бұрын
Sure Shreya 👍👍🙂🙂
Really appreciates ur work 👍. Thanks
@CodeDecode
Жыл бұрын
Thanks Rahul 😁
great thanks!
@CodeDecode
7 ай бұрын
You're welcome!
Hi code decode, I have gone through the multithreading videos 1 and 2. and In interview I have explained thread and how to create etc. Interviewer asked me what is deadlock in threads. and concurrency in threads. and he said if I have multiple threads t1, t2, t3 is there, Is there a way I can call t2 thread first next t3 and t1 to execute. I said Namasthe, I will learn and comeback. Could you please cover those or else If you had already made a video on this could you give me link to it.
next part of multithreading, please
@CodeDecode
3 жыл бұрын
sure we will create one soon
Please upload the part 3 also
@CodeDecode
Ай бұрын
Sure we will upload it soon
Can you please cover ExecutorService, countdownlatch, cyclicbarrier concepts please
next part please
@CodeDecode
Жыл бұрын
Sure we will upload it soon
Mam please make next parts of this series with more important questions
@CodeDecode
2 жыл бұрын
Sure Sreeja we will do that soon 👍🙂
As already said we need microservices video series.
@CodeDecode
3 жыл бұрын
Please click on bell Icon, you will be notified once it's upload 🙂👍👍
very nice if possible cover remaining topics too in threads
@CodeDecode
3 жыл бұрын
Thanks Sekhar 👍🙂. Sure
please bring part 3 for multi threading
@CodeDecode
2 жыл бұрын
sure we will create it soon...
Mam please make other part also by including the topics and practical implementation
@CodeDecode
3 жыл бұрын
Sure Sreeja, we will move this series ahead soon 👍👍
Have you created next part of multithreading video.? like part 3? for life cycle ,sleep and notify and other things..? Please create it . Please create video on deadlock condition and its solution.
please continue next part also
@CodeDecode
3 жыл бұрын
Sure...
Tq
@CodeDecode
2 жыл бұрын
🙂🙂
Please create the next part covering all the remaining multi threading concepts.
@CodeDecode
Жыл бұрын
Sure we will create it soon
@PraveenKumar-ge5zf
Жыл бұрын
@@CodeDecode thanks. Waiting for the same.
Hi ma'am, Waiting for Multithreading related to life cycle, notify, notify all, sleep, wait etc? please upload.
@CodeDecode
2 жыл бұрын
Sure Akash we will upload soon 👍🙂
Very nice . Can you make one video on asynchronous thread using spring @aysnc and also thread pool and Complable & feature objects
@CodeDecode
3 жыл бұрын
Sure Sankar 👍🙂
Plz create a video on executor services as well.. Your video is very helpfull..thank you
@CodeDecode
3 жыл бұрын
sure rachit we will plan and create it soon......
we need more videoes regarding mutithreading
@CodeDecode
Жыл бұрын
sure we will create it soon
Great Video! Part 3 is there?
Thanks 🙏 it really helps, can you please post interview questions on spring framework
@CodeDecode
3 жыл бұрын
Sure 👍👍we will upload spring interview questions soon 👍👍
please give the continuation video of this Part3
@CodeDecode
2 жыл бұрын
Sure 👍
Hi ma'am I have been following your videos and are very helpful. Please can you tell when is the executor frameworks video is coming.
@CodeDecode
Жыл бұрын
Hey Krishna we will create video on executor framework soon.
Please create the third part. Thanks!
Please try to do it 3rd on multithreading
@CodeDecode
2 жыл бұрын
Sure we will upload it soon.....
Can you do a third video of Multithreading related to life cycle, notify, notify all, sleep,wait etc?
@CodeDecode
3 жыл бұрын
Sure Jayant we will surely create that video
Can you please do video on thread life cycle , it would be great help
@CodeDecode
3 жыл бұрын
Sure Nupur, we will cover that too 👍👍
No issue with the pace its ok.. Any Github url? with source code...
Thanks for the concepts! When will the multi threading part 3 be released?
@CodeDecode
2 жыл бұрын
we will make it soon sunantha
please create part 3 of multithreading and contain all the rest things
@CodeDecode
3 жыл бұрын
Sure Vaibhav, we will do that 👍👍
If possible can you please cover the locking mechanism in next part.
@CodeDecode
3 жыл бұрын
Sure Shubham 👍👍
If you have part -1 for Java multithreading , can you include in description???
@CodeDecode
3 жыл бұрын
Updated in the description please check....
Hi Mam, can you plz make video on executorService, callable, Future and completablefuture.
@CodeDecode
3 жыл бұрын
Sure. That mostly asked questions I'm interviews. We will surely create them 👍👍
What if I create a user thread and extend thread class and don’t override run method will user thread be created?
@CodeDecode
3 жыл бұрын
If we don't override Thread class run() method in our defined thread then Thread class run() method will be executed and we will not get any output because Thread class run() is with an empty implementation.
Please create next video
@CodeDecode
2 жыл бұрын
Sure Abhishek 🙂👍
Please create another video on executor framework
@CodeDecode
3 жыл бұрын
Sure Neha 👍👍
When we can expect part 3 of multithreading?? please
@CodeDecode
2 жыл бұрын
Soon Varun 👍🙂
What is the use of daemon thread ?
When we can expect part 3 of multithreading??
@CodeDecode
2 жыл бұрын
We will upload it soon Satyam 👍🙂
Keep it up ladki. :)
@CodeDecode
3 жыл бұрын
Thanks 😁
Is there a third video on this topic?
can you please upload the remaining concepts for multi threading
@CodeDecode
3 жыл бұрын
Sure sri 👍
Where is the next video?
Where is the third part @Code Decode
How to access these docs?
where is part 3