HSL2.0 - Threading
Content
1.
Threading concept HSL20
1.1.
Thread 1 - The logic thread
1.2.
Thread 2 - The HSL 2.0 context thread
1.3.
Threads 3 to n - Own threads
2.
Example of procedure
What are the threads associated with HSL 2.0 devices?

## 1.Threading concept HSL20

There are the following thread contexts with which an HSL 2.0 device comes into contact:

### 1.1.Thread 1 - The logic thread

The HomeServer logic engine runs in a single thread.
In order not to influence the logic in its runtime, an HSL 2.0 module runs in a different thread context (thread 2).
Therefore the framework arranges all input telegrams of an HSL 2.0 block in a queue.
Within the logic thread (Thread 1) the processing of the device is finished.

### 1.2.Thread 2 - The HSL 2.0 context thread

Each HSL 2.0 module determines a context in which it runs. This context is separated from the rest of the logic by its own thread. Within this thread the queue is processed, which contains the input telegrams inserted by thread 1, as well as all calls of callback methods provided by the framework.
This ensures that within a thread/context only one method is running at a time.
Attention
To keep the load on the device low, all blocks within a thread should share a context!

### 1.3.Threads 3 to n - Own threads

It is possible that blocks create their own threads. However, please note that these threads run outside the HSL 2.0 context. This can mean that several things are processed in parallel.
The modules themselves must then ensure multithreading compatibility.

## 2.Example of execution

The block "10704_Telegram generator with random interval.py" can be found in the example folder at `"\threading"`