xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

IsSameThread()

Compares two thread handles.

Syntax

IsSameThread( <pThreadHandle1>, ;
              <pThreadHandle2>  ) --> lIsSameThread

Arguments

<pThreadHandle>
These are the handles of two threads.

Return

The function returns .T. (true) when both thread handles belong to the same thread, otherwise .F. (false) is returned.

Description

The function compares the result of two expressions, or contents of two variables, and returns .T. (true) when both yield a thread handle belonging to the same thread.

Info

See also:GetCurrentThread(), GetThreadID(), IsValidThread(), StartThread(), ThreadSleep()
Category: Multi-threading functions , xHarbour extensions
Source:vm\thread.c
LIB:xhbmt.lib
DLL:xhbmtdll.dll

Example

// The example shows the result of IsSameThread() for running
// and terminated threads. They are the same.

   PROCEDURE Main

      LOCAL pThread1, pThread2
      CLS

      pThread1:= StartThread( "RunInThread" )
      pThread2:= StartThread( "RunInThread" )

      ? IsSameThread( pThread1, pThread2 )  // result: .F.
      ? IsSameThread( pThread1, pThread1 )  // result: .T.

      ThreadSleep( 500 )                    // wait for threads' end

      ? IsSameThread( pThread1, pThread2 )  // result: .F.
      ? IsSameThread( pThread1, pThread1 )  // result: .T.

   RETURN

   PROCEDURE RunInThread()
      ThreadSleep( 100 )
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe