This blog is about providing theory as well as simple executable codes of different programming languages such as java, C, C++, and web programming, etc. This blog will be helpful to the IT students to learn about programming.

Showing posts with label different states of a thread. Show all posts
Showing posts with label different states of a thread. Show all posts

Thursday, March 9, 2023

How thread is created in java? Explain the different states of a thread. Write a program which will display your name in one thread and your address in another thread in every 500 milliseconds. There should be 10000 iteration.

March 09, 2023 0
 In Java, there are two ways to create threads:By implementing the Runnable interface and passing it to a Thread constructor.By extending the Thread class and overriding the run() method.The different states of a thread in Java are:New: When a thread is created but not yet started, it is in the new state.Runnable: When a thread is started, it enters the runnable state. In this state, it is ready to run but may not be currently executing.Running: When...

Slider Widget