org.apache.ignite.thread

## Class IgniteThread

- java.lang.Object
- - java.lang.Thread
  - - org.apache.ignite.thread.IgniteThread

All Implemented Interfaces:
  Runnable

Direct Known Subclasses:
  IgniteSpiThread

    public class IgniteThread
    extends Thread

This class adds some necessary plumbing on top of the `Thread` class. Specifically, it adds:

- Consistent naming of threads
- Dedicated parent thread group
- Backing interrupted flag
- Name of the grid this thread belongs to

Note: this class is intended for internal use only.

### Nested Class Summary

### Nested classes/interfaces inherited from class java.lang.Thread

`Thread.State, Thread.UncaughtExceptionHandler`

### Field Summary

Fields
`static int` `GRP_IDX_UNASSIGNED` Index for unassigned thread.
`protected String` `igniteInstanceName` The name of the Ignite instance this thread belongs to.

### Fields inherited from class java.lang.Thread

`MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

### Constructor Summary

Constructors
`` `IgniteThread(GridWorker worker)` Creates thread with given worker.
`` `IgniteThread(String igniteInstanceName, String threadName, Runnable r)` Creates grid thread with given name for a given Ignite instance.
`` `IgniteThread(String igniteInstanceName, String threadName, Runnable r, int grpIdx, int stripe, byte plc)` Creates grid thread with given name for a given Ignite instance with specified thread group.
`protected` `IgniteThread(String igniteInstanceName, ThreadGroup threadGrp, String threadName)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`boolean` `cachePoolThread()`
`int` `compositeRwLockIndex()`
`void` `compositeRwLockIndex(int compositeRwLockIdx)`
`protected static String` `createName(long num, String threadName, String igniteInstanceName)` Creates new thread name.
`static IgniteThread` `current()`
`boolean` `executingEntryProcessor()`
`String` `getIgniteInstanceName()` Gets name of the Ignite instance this thread belongs to.
`boolean` `holdsTopLock()`
`static void` `onEntryProcessorEntered(boolean holdsTopLock)` Callback before entry processor execution is started.
`static void` `onEntryProcessorLeft()` Callback after entry processor execution is finished.
`byte` `policy()`
`int` `stripe()`
`String` `toString()`

### Methods inherited from class java.lang.Thread

`activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield`

### Methods inherited from class java.lang.Object

`equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### GRP_IDX_UNASSIGNED

    public static final int GRP_IDX_UNASSIGNED

Index for unassigned thread.

See Also:
  Constant Field Values

#### igniteInstanceName

    protected final String igniteInstanceName

The name of the Ignite instance this thread belongs to.

### Constructor Detail

#### IgniteThread

    public IgniteThread(GridWorker worker)

Creates thread with given worker.

Parameters:
  `worker` - Runnable to create thread with.

#### IgniteThread

    public IgniteThread(String igniteInstanceName,
                        String threadName,
                        Runnable r)

Creates grid thread with given name for a given Ignite instance.

Parameters:
  `igniteInstanceName` - Name of the Ignite instance this thread is created for.
  `threadName` - Name of thread.
  `r` - Runnable to execute.

#### IgniteThread

    public IgniteThread(String igniteInstanceName,
                        String threadName,
                        Runnable r,
                        int grpIdx,
                        int stripe,
                        byte plc)

Creates grid thread with given name for a given Ignite instance with specified thread group.

Parameters:
  `igniteInstanceName` - Name of the Ignite instance this thread is created for.
  `threadName` - Name of thread.
  `r` - Runnable to execute.
  `grpIdx` - Thread index within a group.
  `stripe` - Non-negative stripe number if this thread is striped pool thread.

#### IgniteThread

    protected IgniteThread(String igniteInstanceName,
                           ThreadGroup threadGrp,
                           String threadName)

Parameters:
  `igniteInstanceName` - Name of the Ignite instance this thread is created for.
  `threadGrp` - Thread group.
  `threadName` - Name of thread.

### Method Detail

#### policy

    public byte policy()

Returns:
  Related `GridIoPolicy` for internal Ignite pools.

#### stripe

    public int stripe()

Returns:
  Non-negative stripe number if this thread is striped pool thread.

#### cachePoolThread

    public boolean cachePoolThread()

Returns:
  `True` if thread belongs to pool processing cache operations.

#### getIgniteInstanceName

    public String getIgniteInstanceName()

Gets name of the Ignite instance this thread belongs to.

Returns:
  Name of the Ignite instance this thread belongs to.

#### compositeRwLockIndex

    public int compositeRwLockIndex()

Returns:
  Composite RW lock index.

#### compositeRwLockIndex

    public void compositeRwLockIndex(int compositeRwLockIdx)

Parameters:
  `compositeRwLockIdx` - Composite RW lock index.

#### executingEntryProcessor

    public boolean executingEntryProcessor()

Returns:
  `True` if thread is currently executing entry processor.

#### holdsTopLock

    public boolean holdsTopLock()

Returns:
  `True` if thread is currently holds topology lock.

#### onEntryProcessorEntered

    public static void onEntryProcessorEntered(boolean holdsTopLock)

Callback before entry processor execution is started.

#### onEntryProcessorLeft

    public static void onEntryProcessorLeft()

Callback after entry processor execution is finished.

#### current

    public static IgniteThread current()

Returns:
  IgniteThread or `null` if current thread is not an instance of IgniteThread.

#### createName

    protected static String createName(long num,
                                       String threadName,
                                       String igniteInstanceName)

Creates new thread name.

Parameters:
  `num` - Thread number.
  `threadName` - Thread name.
  `igniteInstanceName` - Ignite instance name.
Returns:
  New thread name.

#### toString

    public String toString()

Overrides:
  `toString` in class `Thread`

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.7.5
Release Date | : June 4 2019