Begin detailed description.

This figure contains the pseudocode for a parent thread that creates two child Language Environment® threads. Pseudocode that each child thread executes is also presented.

In the following parent thread, the pthread_create() calls create child thread 1 and child thread 2 respectively. The parent thread persists as the child threads execute.
SQLAllocHandle()(environment)
Initialize shared buffer, set More_Data flag = true
pthread_create (creates child thread 1)
pthread_create (creates child thread 2)
pthread_join
pthread_join
SQLFreeHandle()(environment)
Child thread 1 executes the following pseudocode concurrently with child thread 2 and the parent thread:
SQLAllocHandle() (connection)
SQLConnect()
Connect to database A
SQLAllocHandle()
(statement)
SQLExecDirect()
SQLBindCol()
    Do while More_Data == true
   {
   Place row into shared buffer
   pthread_mutex_lock( &mutex )
   pthread_cond_signal( &cond2 )
    If More_Data == true
    { pthread_cond_wait( &cond1, &mutex ) }
    Else
    { thread_unlock( &mutex ) }
    }
SQLDisconnect(), free handles, and pthread_exit
Child thread 2 executes the following pseudocode concurrently with child thread 1 and the parent thread:
SQLAllocHandle()(connection)
SQLConnect()
Connect to database B
SQLAllocHandle() (statement)
SQLBindParameter()
SQLPrepare()
pthread_mutex_lock( &mutex )
pthread_cond_wait( &cond2 , &mutex )
   Do while More_Data == true
   {
   SQLExecute()
   Insert row from shared buffer into table
   pthread_mutex_lock( &mutex )
   pthread_cond_signal( &cond1 )
   pthread_cond_wait( &cond2 , &mutex )
   }
SQLDisconnect(), free handles, and pthread_exit

End detailed description.