Welcome back to my blog! In my last post, you learned about control statements in Java. In this post, you will learn about multi-threading using thread in Java.
Just follow the steps given below:
So let's get started!
Write the following code:
class Multi_thread extends Thread {
public void run() {
System.out.println("My thread is running...");
public static void main(String args[]) {
Multi_thread obj = new Multi_thread();
obj.start();
}
}
}
Congratulations!!! You have learned multi-threading using thread in Java using Eclipse. If you find this post helpful, please share it with your friends and colleagues.
FEEL LIKE A PROGRAMMER!!!
Just follow the steps given below:
So let's get started!
Step #1: Open Eclipse and select the directory where you want to save your work.
Step #2: Go to File>New>Project.
Step #3: Select Java Project, then click Next..
Step #4: Give the name of your project and click on Finish.
Step #5: You will see a source folder named "src". Add a new class by right-clicking on the source folder>New>Class.
Step #6: You will see a screen like this:
Write the following code:
class Multi_thread extends Thread {
public void run() {
System.out.println("My thread is running...");
public static void main(String args[]) {
Multi_thread obj = new Multi_thread();
obj.start();
}
}
}
Step #7: Click on the Run button to run your program.
Congratulations!!! You have learned multi-threading using thread in Java using Eclipse. If you find this post helpful, please share it with your friends and colleagues.
FEEL LIKE A PROGRAMMER!!!
Comments
Post a Comment