When the processing to be performed within a secondary thread is limited in scope to the data objects "owned" by the current application object, an object window is not warranted. A secondary thread without an object window is similar in both appearance and behavior to a normal subroutine. However, the routine executing in the secondary thread performs its tasks asynchronously to the primary thread, although it still has access to the same data objects. Such a thread is typically started when required by issuing a DosCreateThread() call from within a window procedure in the primary thread. A sample invocation of such a thread is illustrated in Figure "Creating a Thread Without an Object Window".
Two considerations arise when processing asynchronous threads without the use of object windows:
These two conditions may be achieved by adopting a convention whereby a secondary thread has exclusive access to its data object(s) for the duration of its execution. It is therefore only necessary for the primary thread to determine when the secondary thread has completed processing, at which point it may access the data objects.
Where this is not possible, mutex semaphores may be used to serialize access to resources such as data objects. Each thread that requires access must bid for the semaphore. If the semaphore is already held by another thread, the requesting thread must wait for that thread to release the semaphore before attempting to access the resource.
A number of mechanisms for synchronizing execution and/or access to resources are described in Maintaining Synchronization.