Does STC API support multithreading within the port and across ports on the same module?
Knowledge Base - FAQ
N/A
Multithreading Considerations in STC Automation:
The STC exhibits limited support for multithreaded operations. Thread safety and resource consistency are not guaranteed, and behavior varies depending on the threading model used.
1. Multithreading Within a Single Port:
Unsupported Configuration: Concurrent operations targeting the same port (e.g., parallel creation of devices or streams) are not thread safe.
Observed Issues:
Race conditions during object instantiation.
Handle overwrites leading to resource corruption.
Stream creation failures due to non-deterministic execution order.
2. Multithreading Across Ports on the Same Module:
Partially Supported: Concurrent operations across different ports on the same module may succeed in some cases but are not reliably supported.
Observed Issues:
Inconsistent device creation behavior.
Stream creation failures due to argument parsing errors.
Incorrect port-handle mapping across threads, resulting in configuration mismatches.
Recommended Approach: Sequential Threading
To ensure reliable and deterministic behavior in STC automation:
Adopt a sequential threading model, where each thread is executed in isolation — i.e., a thread is started, completed, and joined before the next begins.
This approach maintains a threaded framework structure while ensuring that only one STC operation executes at a time.
Benefits of Sequential Threading:
Eliminates race conditions and handle collisions.
Ensures consistent device and stream creation.
Provides stable and repeatable test execution across environments.
Note: If multithreading is required due to framework architecture, sequential threading is the only advised method for interacting with STC APIs."