-   
- Const-  TLS_OUT_OF_INDEXES  = &HFFFFFFFF
 
- Const-  INFINITE  = 4294967295
 
-   
-   
-   
-   
-   
- Dim As _Offset-  pThreadFunc: pThreadFunc  =-  GetProcAddress (- libload , "ThreadFunc")
 
-   
- 'Allocate a TLS index 
-   
- dwTlsIndex = TlsAlloc 
- If-  dwTlsIndex  =-  TLS_OUT_OF_INDEXES  Then-  _ 
 
-     ErrorExit "TlsAlloc failed" 
-   
- 'Create multiple threads 
-   
-     hThread(i) = CreateThread(0,_ 
-         0,_ 
-         pThreadFunc,_ 
-         0,_ 
-         0,_ 
-   
-     'Check the return value for success 
-         ErrorExit "CreateThread error" 
-   
-     WaitForSingleObject hThread(i), INFINITE 
-   
- TlsFree dwTlsIndex 
- FreeLibrary libload 
-   
-   
-     'Retrieve a data pointer for the current thread 
-   
-     lpvData = TlsGetValue(dwTlsIndex) 
-     If-  lpvData  = 0 And-  GetLastError  <>-  ERROR_SUCCESS  Then-  _ 
 
-         ErrorExit "TlsGetValue error" 
-   
-     'Use the data stored for the current thread 
-   
-     printf  "common: thread %d: lpvData=%lx" + Chr$(10) + Chr$(0),-  GetCurrentThreadId ,-  lpvData 
-   
-   
-     'Initialize the TLS index for this thread 
-   
-     lpvData = LocalAlloc(LPTR, 256) 
-     If-  TlsSetValue (- dwTlsIndex ,-  lpvData ) = 0 Then-  _ 
 
-         ErrorExit "TlsSetValue error" 
-   
-     printf  "thread %d: lpvData=%lx" + Chr$(10) + Chr$(0),-  GetCurrentThreadId ,-  lpvData 
-   
-     CommonFunc 
-   
-     'Release the dynamic memory before the thread returns 
-   
-     lpvData = TlsGetValue(dwTlsIndex) 
-         LocalFree lpvData 
-   
-     ThreadFunc = 0 
-   
-     fprintf stderr , "%s" + Chr$(10) + Chr$(0),-  message  + Chr$(0)
-     ExitProcess 0