Multithreading Interview Questions
Inter-thread communication, as the name suggests, is a process or mechanism using
which multiple threads can communicate with each other. It is especially used to
avoid thread polling in java and can be obtained using wait(), notify(), and notifyAll()
methods.
30. What is Thread Scheduler and Time Slicing?
Thread Scheduler: It is a component of JVM that is used to decide which thread will
execute next if multiple threads are waiting to get the chance of execution. By
looking at the priority assigned to each thread that is READY, the thread scheduler
selects the next run to execute. To schedule the threads, it mainly uses two
mechanisms: Preemptive Scheduling and Time slicing scheduling.
Time Slicing: It is especially used to divide CPU time and allocate them to active
threads. In this, each thread will get a predefined slice of time to execute. When the
time expires, a particular thread has to wait till other threads get their chances to use
their time in a round-robin fashion. Every running thread will get executed for a fixed
time period.
Dostları ilə paylaş: