[fpc-pascal] GetThreadId, GetCurrentThreadId and MainThreadId
vsnijders at vodafonevast.nl
Tue Sep 8 14:02:46 CEST 2009
While investigating http://bugs.freepascal.org/view.php?id=14335 I ran into the
following peculiarities. Please, comment and tell for which item you want bug
reports, if any. I tested on i386-linux.
1. The docs of GetThreadId seems to contain a typo:
"GetThreadID returns the current process ID." -> should be thread ID.
2. The docs of MainThreadID say it is unused. But it is used in TThread.Synchronize.
Given the following program:
3. If cthreads is not used, all values are 1. No problem with that, although I am
not sure those are real thread id, at least on i386-win32 the value changes on each
run, e.g. 1908, 576, maybe because threadmanager is already included in windows.
Anyway, this is not a problem, as long as they all have the same value in a single
If cthreads is used, I get the following output:
4. What is the difference between GetThreadID and GetCurrentThreadID? This code runs
in the same thread, so I expect the same value.
More information about the fpc-pascal