---
title: "Threads Interface"
url: https://develop.sentry.dev/sdk/foundations/transport/event-payloads/threads/
---

# Threads Interface

The Threads Interface specifies threads that were running at the time an event happened. These threads can also contain stack traces.

An [event](https://develop.sentry.dev/sdk/foundations/transport/event-payloads.md) may contain one or more threads in an attribute named `threads`.

The `threads` attribute should be an object with the attribute `values` containing one or more values that are objects in the format described below. Alternatively, the `threads` attribute may be a flat list of objects in the format below.

As per Sentry policy, the thread that crashed with an [exception](https://develop.sentry.dev/sdk/telemetry/errors.md) should not have a stack trace, but instead, the `thread_id` attribute should be set on the exception and Sentry will connect the two.

## [Attributes](https://develop.sentry.dev/sdk/foundations/transport/event-payloads/threads.md#attributes)

* `id`

  **Required**. The ID of the thread. Typically a number or numeric string.Needs to be unique among the threads. An exception can set the `thread_id`attribute to cross-reference this thread.

* `crashed`

  *Optional*. A flag indicating whether the thread was the cause for the event being sent, e.g. due to a crash.Defaults to `false`.

* `current`

  *Optional*. A flag indicating whether the thread was in the foreground. A thread is in foreground when it's executing.Defaults to `false`.

* `main`

  *Optional*. If applicable, a flag indicating whether the thread was responsible for rendering the user interface.On mobile and desktop platforms this is oftentimes referred to as the "main thread" or "ui thread".

* `name`

  *Optional*. The thread name.

* `state`

  *Optional*. State of the thread at the time of the event.

* `held_locks`

  *Optional*. Represents a collection of locks (monitor objects) held by a thread. A dictionary of lock object memory addresses andtheir respective lock reason/details. Lock reason corresponds to the [Lock Reason Interface](https://develop.sentry.dev/sdk/foundations/transport/event-payloads/lockreason.md).

* `stacktrace`

  *Optional*. A stack trace object corresponding to the [Stack Trace Interface](https://develop.sentry.dev/sdk/foundations/transport/event-payloads/stacktrace.md).

If this is an error event, the stack trace of the main exception should be declared in the [Exception Interface](https://develop.sentry.dev/sdk/telemetry/errors.md#wire-format) instead. Sentry will automatically move the stack trace of the only crashed thread, if there is a single exception.

## [Examples](https://develop.sentry.dev/sdk/foundations/transport/event-payloads/threads.md#examples)

The following example illustrates the threads part of the [event payload](https://develop.sentry.dev/sdk/foundations/transport/event-payloads.md) and omits other attributes for simplicity.

```json
{
  "threads": {
    "values": [
      {
        "id": "0",
        "name": "main",
        "crashed": true,
        "main": true,
        "held_locks": {
          "0x0d3a2f0a": {},
          "0x07d7437b": {}
        },
        "state": "Waiting",
        "stacktrace": {}
      }
    ]
  }
}
```

Or, alternatively:

```json
{
  "threads": [
    {
      "id": "0",
      "name": "main",
      "crashed": true,
      "main": true,
      "held_locks": {
        "0x0d3a2f0a": {},
        "0x07d7437b": {}
      },
      "state": "Runnable",
      "stacktrace": {}
    }
  ]
}
```
