詳細な説明の開始

この図には、2 つの言語処理環境の子スレッドを 作成する親スレッドの疑似コードが含まれています。 また、それぞれの子スレッドが実行する疑似コードも示されています。

以下の親スレッドでは、pthread_create() 呼び出しにより、子スレッド 1 および 子スレッド 2 がそれぞれ作成されます。親スレッドは、子スレッドが実行している間、存続しています。
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)
子スレッド 1 は、子スレッド 2 および親スレッドと並行して、以下の疑似コードを実行します。
SQLAllocHandle() (connection)
SQLConnect()
Connect to database A
SQLAllocHandle()
(ステートメント)
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
子スレッド 2 は、子スレッド 1 および親スレッドと並行して、 以下の疑似コードを実行します。
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

詳細な説明の終了