> For the complete documentation index, see [llms.txt](https://boxlang.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boxlang.ortusbooks.com/boxlang-language/reference/components/async/thread.md).

# Thread

The thread component enables multithreaded programming in BoxLang.

## Component Signature

```
<bx:Thread name=[string]
action=[string]
duration=[integer]
priority=[string]
timeout=[integer]
virtual=[boolean] />
```

### Attributes

| Atrribute  | Type      | Required | Description                                                                                                                                                                                                                             | Default  |
| ---------- | --------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `name`     | `string`  | `false`  | The name of the thread.                                                                                                                                                                                                                 |          |
| `action`   | `string`  | `false`  | The action to perform. The default value is "run". The following are the possible values: "join", "run", "sleep", "terminate".                                                                                                          | `run`    |
| `duration` | `integer` | `false`  | The number of milliseconds to pause the thread. This attribute is required if the action attribute is set to "sleep".                                                                                                                   | `0`      |
| `priority` | `string`  | `false`  | The priority of the thread. The default value is "normal". The following are the possible values: "high", "low", "normal".                                                                                                              | `normal` |
| `timeout`  | `integer` | `false`  | <p>The number of milliseconds to wait for the thread to finish. If the thread does not finish within the specified time, the thread<br>is terminated. If the timeout attribute is not specified, the thread runs until it finishes.</p> |          |
| `virtual`  | `boolean` | `false`  | If true, the thread will be a [virtual thread](https://docs.oracle.com/en/java/javase/21/core/virtual-threads.html). Default is false.                                                                                                  | `false`  |

## Examples

### Script Syntax

```java
// do single thread stuff
bx:thread action="run" name="myThread";
bx:thread action="join" name="myThread,myOtherThread";

```

### Tag Syntax

```java
<bx:thread action="run" name="myThread">
 <!--- Do single thread stuff ---> 
 </bx:thread> 
 <bx:thread action="join" name="myThread,myOtherThread"/>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/components/async/thread.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
