class documentation

class ThreadSafeCounter:

Constructor: ThreadSafeCounter(initial)

View In Hierarchy

A thread-safe counter.

Method __init__ Initialize the counter with an initial value.
Method decrement Decrement the counter.
Method increment Increment the counter.
Method value Get the counter value.
Instance Variable counter The counter value.
Instance Variable lock The lock object.
def __init__(self, initial: int = 0):

Initialize the counter with an initial value.

Parameters
initial:intThe initial counter value.
def decrement(self, value: int = 1) -> int:

Decrement the counter.

Parameters
value:intThe value to decrement the counter by.
Returns
intThe new counter value.
def increment(self, value: int = 1) -> int:

Increment the counter.

Parameters
value:intThe value to increment the counter by.
Returns
intThe new counter value.
def value(self) -> int:

Get the counter value.

Returns
intThe current counter value.
counter: int =

The counter value.

lock =

The lock object.