> ## Documentation Index
> Fetch the complete documentation index at: https://developer.synopsys.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Class: PHXBlocker

**Package:** `com.phoenix_int.util`

**Class Hierarchy**

```java theme={null}
↳ java.lang.Object
  ↳ com.phoenix_int.util.PHXBlocker
```

***

**Declaration**

```java theme={null}
public class PHXBlocker
extends java.lang.Object
```

Class to simplify wait and notify calls. Can be used to block one thread until some other thread signals a continue.

**Sample usage:**

```java theme={null}
import com.phoenix_int.util.PHXBlocker;
//
public class PHXThingie
{
   PHXBlocker _blocker;
   public PHXThingie()
   {
      _blocker = new PHXBlocker(); //create the blocker.
      //You must call setBlock(true) before block.  You should
      //do it in a place before it is ever possible(however remote)
      //that some other thread calls unblock first.  In this case,
      //before the subthread is started.
      _blocker.setBlock(true);    
//
      MyThread t = new MyThread();
      t.start();                   //make a new thread that will unblock.
//
      System.out.println("hi");
      _blocker.block();            //this is the crux!
      System.out.println("there");
   }
//
   //Thread that just sits around for 10 secs and then unblocks.
   private class MyThread extends Thread
   {
      public void run()
      {
         try
         {
            sleep(10000);
         } catch(InterruptedException ie)
         {}
         _blocker.unblock();
      }
   }
}
```

## Field Summary

| Modifier and Type | Field and Description |
| - | - |
| `static java.lang.String` | `rcsid` |

## Constructor Summary

| Constructor and Description |
| - |
| `PHXBlocker()` |

## Method Summary

| Modifier and Type | Method and Description |
| - | - |
| `void` | `block()` Blocks until unblock() is invoked. |
| `boolean` | `block(long timeout)` Blocks until unblock is invoked or timeout has been reached |
| `boolean` | `getBlock()` |
| `void` | `setBlock(boolean block)` Call setBlock() before block() and before there is any remote chance that any other thread will call unblock(). |
| `void` | `unblock()` |
| `void` | `unblockAll()` Same as unblock except designed for multiple waiters. |

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

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

## Field Detail

### rcsid

```java theme={null}
public static final java.lang.String rcsid
```

**See Also:**

* [Constant Field Values](https://developer.synopsys.com/docs/modelcenter/modelcenter-remote-execution-java-api/constant-values.md)

## Constructor Detail

### PHXBlocker

```java theme={null}
public PHXBlocker()
```

## Method Detail

### setBlock

```java theme={null}
public void setBlock(boolean block)
```

Call `setBlock()` before `block()` and before there is any remote chance that any other thread will call `unblock()`.

### getBlock

```java theme={null}
public boolean getBlock()
```

### block

```java theme={null}
public boolean block(long timeout)
```

Blocks until unblock is invoked or timeout has been reached

**Parameters:**

* `timeout` - Maximum time to wait in milliseconds. Set to 0 to wait forever.

**Returns:**

* `true` if correctly unblocked. `false` if interrupted or timeout.

### block

```java theme={null}
public void block()
```

Blocks until `unblock()` is invoked.

### unblock

```java theme={null}
public void unblock()
```

### unblockAll

```java theme={null}
public void unblockAll()
```

Same as unblock except designed for multiple waiters. If there is any chance of multiple people having called `block()`, then use `unblockAll()`.
