---
title: "How to Create thread in java?"  
description: "How to Create thread in java?"  
author: "Anonymous User"  
published: 2014-10-10  
updated: 2014-10-10  
canonical: https://www.mindstick.com/forum/2352/how-to-create-thread-in-java  
category: "java"  
tags: ["java", "oops"]  
reading_time: 1 minute  

---

# How to Create thread in java?

Thread creating in [java](https://www.mindstick.com/articles/12214/web-development-company-in-india-laid-on-the-foundation-of-concrete-java-programming)

## Replies

### Reply by Anonymous User

**ThreadTest.Java**

```
    public class ThreadTest    {        public static void main(String[] args)        {            MyThread t1 = new MyThread(0, 3, 300);            MyThread t2 = new MyThread(1, 3, 300);            MyThread t3 = new MyThread(2, 3, 300);             t1.start();            t2.start();            t3.start();        }    }
```

**MyThread.java**

```
public class MyThread extends Thread{   private int startIdx, nThreads, maxIdx;    public MyThread(int s, int n, int m)   {      this.startIdx = s;      this.nThreads = n;      this.maxIdx = m;   }    @Override   public void run()   {      for(int i = this.startIdx; i < this.maxIdx; i += this.nThreads)      {         System.out.println("[ID " + this.getId() + "] " + i);      }   }}
```

\


---

Original Source: https://www.mindstick.com/forum/2352/how-to-create-thread-in-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
