// Import necessary classes import java.lang.Thread; // HelloWorldThread class extending the Thread class public class HelloWorldThread extends Thread { @Override public void run() { // This code will be executed in a separate thread System.out.println("Hello, World from a thread!"); } public static void main(String[] args) { // Create a new instance of the HelloWorldThread HelloWorldThread myThread = new HelloWorldThread(); // Start the thread using the start() method myThread.start(); } }