Thread isAlive() and join() Methods in Java

Here we will discuss the Thread isalive() and join() method in java There are two ways to determine whether a thread has finished or not. Read More: Thread Concepts Thread Life Cycle in JavaMultithreading in Java Thread Creation Method Use ExampleThread Priorities in JavaMain Thread in JavaThread Yield method in JavaThread Synchronization in JavaThread suspend() … Read more

Producer Consumer Problem in Java

In computing, producer–consumer problem is also known as the bounded buffer problem. In the producer–consumer problem there are two processes, first is the producer and the second is the consumer, who share a common, fixed-size buffer.  The producer’s job is to generate data, put it into the buffer and start again. At the same time, … Read more

Thread stop method in Java

In java, stop()  method  kills/terminates  the currently executing thread.

Result

Description: in the above program, when value of variable i=3 then stop() method terminates the curently executing thread and come out of the loop.

Thread Yield method in Java

In java, yield()  method  temporarily pause  the currently executing thread object  and allow other threads to execute.

Thread suspend() and resume() method in Java

suspend() : This method suspend a thread for sometime but do not kill/terminate it. resume() : This method revives the suspended thread.

Java Applet Example

To run applets we use  appletviewer . An appletviewer is command line program to invoke an applet program from command line. Here we will see how to run applet from applet viewer Example : Write a simple applet program to print “ Hello Students”

Compile  Save & Run:  Save this file with APDemo.java name. Compile : … Read more

Thread Life Cycle in Java

Thread Life Cycle in Java tells the various information of thread form born to terminate. Thread life cycle contains the several stages and at a time any thread can be present  in a single state. States of Thread life cycle Born Ready Running Blocked Sleep Wait Dead Ready:  In this state thread is ready to … Read more

Thread Synchronization in Java

When two or more threads try to access the same resource, they need somehow to ensure that the resource will be used by only one thread at a time. The process by which this achive is called Synchronization. Java uses the concept of monitor (also called semaphore) for Synchronization. The monitor allows one thread at … Read more

Thread Priorities in Java

In java, when two or more than  two thread is computing for CPU time, every thread is assigned a priority value. A highest Priority thread get preference over lower priority thread.   All Java threads have a priority in the range 1-10. Top priority is 10, lowest priority is 1.Normal priority ie. priority by default … Read more