THREAD (return current execution thread)

Top  Previous  Next

 

THREAD( )

The THREAD procedure returns the currently executing thread number. The returned thread number can be used by procedures and built-in procedures whose action may be performed on any execution thread (such as SETTARGET).

The maximum number of simultaneously available execution threads in a single application is theoretically unlimited. However, the word "unlimited" means that limits are applied not by the Clarion Runtime Library, but by the Operating System’s environment settings, i.e., limited to the amount of virtual memory available for the process, or limited number of threads in the system, or limited number of windows (including controls) that can be opened simultaneously in the process, etc. Therefore, THREAD always returns a value in the range of one (1) to the upper limit of the SIGNED integer (2,147,483,647).

Return Data Type:     SIGNED

Example:

MainWin APPLICATION('My Application'),SYSTEM,MAX,ICON('MyIcon.ICO'),STATUS |

 ,HVSCROLL,RESIZE

        MENUBAR

         MENU('&File'),USE(?FileMenu)

          ITEM('Selection &1...'),USE(?MenuSelection1)

          ITEM('Selection &2...'),USE(?MenuSelection2)

         END

        END

       END

 

SaveThread   LONG                  !Declare thread number save variable

SaveThread1  LONG                  !Declare thread number save variable

SaveThread2  LONG                  !Declare thread number save variable

CODE

SaveThread = THREAD()             !Save thread number

OPEN(MainWin)                     !Open the APPLICATION

ACCEPT                            !Handle Global events

 CASE ACCEPTED()

 OF ?MenuSelection1

  SaveThread1 = START(NewProc1)   !Start a new thread

 OF ?MenuSelection2

  SaveThread2 = START(NewProc2)   !Start a new thread

 OF ?Exit

  RETURN

 END

END

 

See Also:

START