JAVA Tutorials

Thread Synchronization Practices in Java : Free Java Tutorials

We must follow some practices and rules while performing thread synchronization in Java. Every Java object has synchronized as well as non-synchronized area. The non-synchronized portion of an object can be accessed by multiple threads simultaneously. Whereas, the synchronized area can be accessed by only one thread at a time. Whenever we perform any update operation …

Thread Synchronization Practices in Java : Free Java Tutorials Read More »

Thread Prevention using sleep Method in Java : Free Java Tutorials

Thread Prevention can also be done using sleep method. If a thread does not want to perform any operation for a specific amount of time, then we should go for sleep method. Sleep method causes thread execution to pause for the specified period of time. We will understand in detail about sleep method in this …

Thread Prevention using sleep Method in Java : Free Java Tutorials Read More »

Thread Prevention and Deadlock in Java : Free Java Tutorials

Thread Prevention using join() method sometimes causes an unintended deadlock situation to arise. A deadlock situation occurs when there is a circular chain of threads each waiting for the other thread to finish its execution. Join() method can also be used to prevent child thread from executing before main thread. To do this, we have to …

Thread Prevention and Deadlock in Java : Free Java Tutorials Read More »

Thread Prevention using yield Method in Java : Free Java Tutorials

Thread prevention deals with how we can prevent a thread from executing on a temporary or permanent basis. We can prevent thread execution by using the 3 methods in Java namely yield, join and sleep method. Before understanding thread prevention, let’s first understand the life cycle of a thread. Look at the following diagram which …

Thread Prevention using yield Method in Java : Free Java Tutorials Read More »