# WrappedThread

`com.jsmacrosce.jsmacros.graal.language.impl.WrappedThread`

Associates a Java thread with its Graal task-queue priority and a one-way readiness signal.  
```js
const WrappedThread = Java.type("com.jsmacrosce.jsmacros.graal.language.impl.WrappedThread");  
const Thread = Java.type("java.lang.Thread");  
const task = new WrappedThread(Thread.currentThread(), 5);  
task.notifyReady();  
task.waitUntilReady(); // already signaled: returns without parking
```

Do not block a script waiting for a notifier that has not been scheduled.

## Constructors

### new WrappedThread {#com.jsmacrosce.jsmacros.graal.language.impl.WrappedThread_constructor-Thread-int-}

```js
new WrappedThread(Thread thread, int priority)
```

Stores the thread and queue priority; the readiness signal starts unset.

**Parameters:**
- `thread`: Java thread represented by this task
- `priority`: Graal task-queue priority, not Java thread priority

## Fields

### priority {#com.jsmacrosce.jsmacros.graal.language.impl.WrappedThread_priority}

```js
priority: int
```

Graal task-queue priority value, not a `Thread.setPriority` value.

### thread {#com.jsmacrosce.jsmacros.graal.language.impl.WrappedThread_thread}

```js
thread: Thread
```

The Java thread represented by this task; this reference is not copied or started.

## Methods

### notifyReady {#com.jsmacrosce.jsmacros.graal.language.impl.WrappedThread_notifyReady-}

```js
notifyReady(): void
```

Sets readiness and unparks the represented thread; readiness is one-way.

### waitUntilReady {#com.jsmacrosce.jsmacros.graal.language.impl.WrappedThread_waitUntilReady-}

```js
waitUntilReady(): void
```

Waits for readiness on the represented thread; another caller receives an `AssertionError`.  
Parks while not ready. After each park, an interrupt clears the current thread's interrupt status
and causes `InterruptedException`; an already-ready call returns without checking it.
