Sunday, 11 June 2017

Java Tutorial : Java Threads (How to create a thread in java | Java thread Creation) ~ foundjava


Click here to watch in Youtube : 


Click the below Image to Enlarge

Java Tutorial : Java Threads (How to create a thread in java | Java thread Creation) 

Java Tutorial : Java Threads (How to create a thread in java | Java thread Creation) 

Java Tutorial : Java Threads (How to create a thread in java | Java thread Creation) 

Java Tutorial : Java Threads (How to create a thread in java | Java thread Creation) 
HelloRunnable.java
public class HelloRunnable implements Runnable
{

    public static void main(String args[])
    {
        HelloRunnable helloRunnable = new HelloRunnable();
        Thread thread = new Thread(helloRunnable);
        thread.start();
    }

    @Override
    public void run()
    {
        System.out.println("Hello from a thread!");
    }
}
Output
Hello from a thread!

HelloThread.java
public class HelloThread extends Thread
{

    public static void main(String args[])
    {
        HelloThread helloThread = new HelloThread();
        helloThread.start();
    }
    
    @Override
    public void run()
    {
        System.out.println("Hello from a thread!");
    }

}
Output
Hello from a thread!
Click the below link to download the code:

CLICK HERE

No comments:

Post a Comment