Category: Multi Threading
What is Daemon thread and How to make Daemon thread? The threads which are executing in the background are called Demon threads. Ex… Garbage Collector, Signal Dispatcher, Attach Listener. The main objective of demon threads is to provide support for non-demon threads(main thread) For ex… If the main thread runs . . . Read more
What is DeadLock and difference between DeadLock and Starvation? If two threads are waiting for each other forever such type of infinite waiting is called deadlock. Synchronized is the only reason for deadlock situation hence while using synchronized keyword we have to take special care. There is no resolution technique . . . Read more
What is synchronization and why it is important? Synchronized is the modifier applicable only for methods and blocks but not for classes and variables. If multiple threads are trying to operate simultaneously on the same java object then there may be a chance of data-inconsistency problem. To overcome this problem we should go . . . Read more
Difference between yield(), join(), sleep() method? We can prevent thread execution by using the following method. yield() join() sleep() public static native void yield()Â yield() method causes to pause current executing thread to give the chance for waiting threads of the same priority. If there is no waiting thread or . . . Read more
Explain thread priority and what is default thread priority? Every thread in java has some priority. It may be default priority generated by JVM or customized priority provided by the programmer. The valid range of thread priorities is 1-10. where 1 is min priority and 10 is the max priority. . . . Read more
What is Multi-Threading and how we can define a thread? Executing several tasks simultaneously where each task is a separate independent part of the same program is called thread-based multitasking and each independent part is called a thread. Thread-based multitasking is best suitable at a programmatic level. Whether it is . . . Read more
What is Volatile keyword in Java? Volatile is the modifier applies only to variables and we can’t apply anywhere else. If the value of a variable keeps on changing by multiple threads then there may be a chance of data inconsistency problem. We can solve this problem by using the . . . Read more
What is synchronized modifier in Java? Synchronized is the modifier applicable for methods and blocks but not classes and variables. If multiple threads trying to operate simultaneously on the same java object then there may be a chance of data inconsistency problem this is called race condition. We can overcome . . . Read more