GetThreadID and GetCurrentThreadID return different values.
Original Reporter info from Mantis: wimpie
-
Reporter name: Wimpie Nortje
Original Reporter info from Mantis: wimpie
- Reporter name: Wimpie Nortje
Description:
GetThreadID and GetCurrentThreadID return different values when called within the same thread.
I think GetCurrentThreadID returns the proper value because in a multithreaded app it returns the same value as MainThreadID if called from within the main thread.
Steps to reproduce:
From an email by Vincent:
Given the following program:
program project1;
{$mode objfpc}{$H+}
uses
//cthreads,
Classes;
begin
writeln('GetThreadID=', GetThreadID);
writeln('GetCurrentThreadID=', GetCurrentThreadId);
writeln('MainThreadID=', MainThreadID);
end.
- 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 threaded application
If cthreads is used, I get the following output:
GetThreadID=3084795456
GetCurrentThreadID=3085236992
MainThreadID=3085236992
Mantis conversion info:
- Mantis ID: 15821
- OS: Windows and Linux
- OS Build: ? and Ubuntu9.10
- Platform: ? and i386 32b
- Version: 2.4.0
- Fixed in version: 2.4.2
- Fixed in revision: 15175 (#75b5b6c7)
- Target version: 2.4.2