Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-02

Thread IDs

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jonas Maebe
to Wimpie Nortje
Wimpie Nortje wrote
What is the difference between GetThreadID() and GetCurrentThreadID()?

There is a threadvar called "threadid" in the system unit. When a new thread is started, GetCurrentThreadID is called to obtain the thread id of the new thread (via the thread manager) and the result is stored in the threadid threadvar. GetThreadID simply returns the value of this threadvar.

So in summary: there is no semantic difference.

Jonas

Reply by email

Wimpie Nortje
to Jonas Maebe
Jonas Maebe wrote 13 lines
On 18 Feb 2010, at 16:35, Wimpie Nortje wrote: > What is the difference between GetThreadID() and GetCurrentThreadID()? There is a threadvar called "threadid" in the system unit. When a new thread is started, GetCurrentThreadID is called to obtain the thread id of the new thread (via the thread manager) and the result is stored in the threadid threadvar. GetThreadID simply returns the value of this threadvar. So in summary: there is no semantic difference.

They return different values. I think GetCurrentThreadID is the more trustworthy one. When control returns to my main thread then GetCurrentThreadID = MainThreadID and GetThreadID MainThreadID

Reply by email

Vincent Snijders
to Wimpie Nortje
Wimpie Nortje wrote 19 lines
Jonas Maebe wrote: > > On 18 Feb 2010, at 16:35, Wimpie Nortje wrote: > >> What is the difference between GetThreadID() and GetCurrentThreadID()? > > There is a threadvar called "threadid" in the system unit. When a new > thread is started, GetCurrentThreadID is called to obtain the thread > id of the new thread (via the thread manager) and the result is stored > in the threadid threadvar. GetThreadID simply returns the value of > this threadvar. > > So in summary: there is no semantic difference. > They return different values. I think GetCurrentThreadID is the more trustworthy one. When control returns to my main thread then GetCurrentThreadID = MainThreadID and GetThreadID MainThreadID

I found some inconsistencies a couple of months ago, but never got to creating a bug report:

lists.freepascal.org seems down, so I found this link.

VIncent

Reply by email