Synchronizing multiple threads using TEvent

The synchronization details we discussed so far were related to a data flow that is generated in the background thread context and has to be used in another thread. The other thread can be the main thread or another background thread. In this recipe, you'll use a simple synchronization mechanism called event that can be useful when you have to notify a new state, not necessarily new data. Obviously, the new state could also mean there is new data to handle. In such cases, the state change alerts you about new data being available.

Getting ready

The recipe scenario is simple: you have a lot of running threads that are doing something for you. You want to know when all of them are terminated. In this case, ...

Get Delphi Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.