# EventLockWatchdog

`com.jsmacrosce.jsmacros.core.EventLockWatchdog`

Monitors an event-container lock and closes its script context if the lock remains held at the timed check.  
 ```js
const Watchdog = Java.type("com.jsmacrosce.jsmacros.core.EventLockWatchdog");  
const run = JsMacros.runScript("js", "const result = 1 + 1;");  
Watchdog.startWatchdog(run, null, 1000);  
 ```

## Nested types

- [WatchdogException](EventLockWatchdog.WatchdogException.md)

## Constructors

### new EventLockWatchdog {#com.jsmacrosce.jsmacros.core.EventLockWatchdog_constructor-}

```js
new EventLockWatchdog()
```

## Methods

### startWatchdog {#com.jsmacrosce.jsmacros.core.EventLockWatchdog_startWatchdog-EventContainer-IEventListener-long-}

```js
static startWatchdog(EventContainer<?> lock, IEventListener listener, long maxTime): void
```

Starts a lock monitor using the container's context and runner.  
 After the delay, the monitor checks whether the lock is held; if so, it disables a [BaseListener](event/BaseListener.md) listener, closes the context, and logs a [WatchdogException](EventLockWatchdog.WatchdogException.md).  
 A release observed at the check avoids those actions; a release after the check may still race with them. Other listener implementations are not disabled.

**Parameters:**
- `lock`: non-null container with a non-null context and initialized runner thread pool
- `listener`: nullable listener; only a [BaseListener](event/BaseListener.md) is disabled when the timed check finds the lock held
- `maxTime`: nonnegative delay before the timed check, in milliseconds
