Java thread Programming - Create a Basic Thread to Print "Hello, World!"
Java Thread: Exercise-1 with Solution
Write a Java program to create a basic Java thread that prints "Hello, World!" when executed.
Sample Solution:
Java Code:
public class Hello_world_thread extends Thread {
@Override
public void run() {
System.out.println("Hello, World!");
}
public static void main(String[] args) {
Hello_world_thread thread = new Hello_world_thread();
thread.start();
}
}
Sample Output:
Hello, World!
Explanation:
In the above exercise,
In the main method, an instance of the Hello_world_thread class is created, and the start() method is called on that instance. This starts the thread's execution, which invokes the over ridden run() method.
When the program is executed, it creates another thread and runs it, causing "Hello, World!" to be printed to the console.
Flowchart:

Java Code Editor:
Improve this sample solution and post your code through Disqus
Previous: Java Thread Exercises Home.
Next: Find and Print Even-Odd Numbers with Threads.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join