Thread
Two requests update the same cache. Confirm whether they are threads in one process and make the shared-state order explicit.
Two requests update the same cache. Confirm whether they are threads in one process and make the shared-state order explicit.
Sharing eases communication but exposes interference.
Problem and key mechanism: When two threads in one process read and write a shared cache at the same time, a later write can overwrite an earlier result; after confirming the shared object and thread relationship, use a lock, queue, or immutable result to order writes and record observable state.
Verify stable shared results: Repeated concurrent runs should keep the correct final value. Threads still share the process failure and memory boundary.
Video export also uses shared threads: When a video exporter processes segments on multiple threads, they share one progress counter. Updates must be synchronized to prevent regressions or missed progress.
Identify which threads belong to the same process and which state they share. Add an appropriate synchronization boundary around shared-cache writes and record process ID, thread ID, and final value. Run two threads concurrently several times and verify no update is lost.