---
title: "init(value:)"
framework: dispatch
role: symbol
role_heading: Initializer
path: "dispatch/dispatchsemaphore/init(value:)"
---

# init(value:)

Creates new counting semaphore with an initial value.

## Declaration

```swift
init(value: Int)
```

## Parameters

- `value`: The starting value for the semaphore. Do not pass a value less than zero.

## Return Value

Return Value The newly created semaphore.

## Discussion

Discussion Passing zero for the value is useful for when two threads need to reconcile the completion of a particular event. Passing a value greater than zero is useful for managing a finite pool of resources, where the pool size is equal to the value. important: Calls to signal() must be balanced with calls to wait(). Attempting to dispose of a semaphore with a count lower than value causes an EXC_BAD_INSTRUCTION exception.
