filmov
tv
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:
Course Description Video :
Multi threading Interview questions part 1
Q) How to make a user thread to a Daemon thread
make a user thread to Daemon by using setDaemon() method of thread class.
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.
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
----------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------
Subscriber and Follow Code Decode
#javainterviewquestions #multithreadinginterviewquestions #codedecode
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
Course Description Video :
Multi threading Interview questions part 1
Q) How to make a user thread to a Daemon thread
make a user thread to Daemon by using setDaemon() method of thread class.
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.
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
----------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------
Subscriber and Follow Code Decode
#javainterviewquestions #multithreadinginterviewquestions #codedecode
Комментарии