Posts

Showing posts with the label Runnable

Threads in java with example

Image
Read this article to know what is thread and what is the lifecycle of thread in java. Threads concept introduced in java to achieve multiprocessing. Thread represents a separate path of program execution. All threads are running on top of the Main thread in java. This main thread is called daemon thread. Explanation: A thread represents a separate path of execution of a group of statements. In a Java program, if we write a group of statements, then these statements are executed by JVM one by one. This execution is called thread, because JVM uses a thread to execute these statements. This means in every Java program there is thread is running internally. Let us see the below program to find the thread used by JVM to execute the statements: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 package com . javatbrains . threads ; public class CurrentThread { public static void main ( String [] args ) { System . out . println ( "Let us f