Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

# ThreadFactory


`
public


interface
ThreadFactory
`


`


`

|---|
| java.util.concurrent.ThreadFactory |

<br />

*** ** * ** ***

An object that creates new threads on demand. Using thread factories
removes hardwiring of calls to `https://developer.android.com/reference/java/lang/Thread#Thread(java.lang.Runnable)`,
enabling applications to use special thread subclasses, priorities, etc.


The simplest implementation of this interface is just:

    class SimpleThreadFactory implements ThreadFactory {
      public Thread newThread(Runnable r) {
        return new Thread(r);
      }
    }

The `https://developer.android.com/reference/java/util/concurrent/Executors#defaultThreadFactory()` method provides a more useful simple implementation, that sets the created thread context to known values before returning it.

<br />

**See also:**

- `https://developer.android.com/`

## Summary

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/java/lang/Thread` | ` https://developer.android.com/reference/java/util/concurrent/ThreadFactory#newThread(java.lang.Runnable)(https://developer.android.com/reference/java/lang/Runnable r) ` Constructs a new unstarted `Thread` to run the given runnable. |

## Public methods

### newThread

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract Thread newThread (Runnable r)
```

Constructs a new unstarted `Thread` to run the given runnable.

<br />

| Parameters ||
|---|---|
| `r` | `Runnable`: a runnable to be executed by new thread instance <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Thread` | constructed thread, or `null` if the request to create a thread is rejected <br /> |

**See also:**

- [Inheritance when
  creating threads](https://developer.android.com/reference/java/lang/Thread.html#inheritance)