>>> Each threads have separate stack and share common java heap. Stack elements are method and method level variables.
>>> Synchronization is a process of controlling the access of shared resources by the multiple threads in such a manner that only one thread can access a particular resource at a time.
>>> Daemon threads are threads with low priority and runs in the back ground doing the garbage collection operation for the java runtime system. The setDaemon() method is used to create a daemon thread.
>>> The wait(), notify() and notifyAll() methods are used to provide an efficient way for thread inter-communication.
>>> After a thread is started, via its start() method of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed.
>>> Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then re-enters the pool of ready tasks. The scheduler then determines which task should execute next, based on priority and other factors.
Implement Runnable vs Extends Thread
1. Implementing Runnable allows multiple inheritance.
2. If you are not extending any class, better extend Thread class as it will save few lines of coding.
3. Performance wise, there is no distinguishable difference.
What is Thread Pool? How it is implemented?
No comments:
Post a Comment