Sign in Join

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

Mailing lists / fpc-pascal / 2017-03

Thread Variables Initial Values

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

African Wild Dog

Hello,

The documentation is not clear about the initial values of thread variables:

*"If threads are used then a copy is made for each thread (including the main thread). Note that the copy is made with the original value of the variable, not with the value of the variable at the time the thread is started."*
So, if i declare a threadvar:

threadvar
  MyObject: TObject;

What will be the initial value of the variable when each thread uses its copy for the first time?

Regards

Michael Van Canneyt
to African Wild Dog
African Wild Dog wrote 19 lines
Hello, The documentation is not clear about the initial values of thread variables: *"If threads are used then a copy is made for each thread (including the main thread). Note that the copy is made with the original value of the variable, not with the value of the variable at the time the thread is started."* So, if i declare a threadvar: threadvar MyObject: TObject; What will be the initial value of the variable when each thread uses its copy for the first time?

Nil.

What exactly is not clear about the documentation ?

Michael.

African Wild Dog
to Michael Van Canneyt

2017-03-17 13:09 GMT-03:00 Michael Van Canneyt :

Show quoted text 5 lines
Nil. What exactly is not clear about the documentation ?

The documentation says ".. Note that the copy is made with the original value of the variable ..". But, whats is the original value? I think the documentation should be clearer about the initial values of thread variables. From what i I understand, the value is default(T) for all threads. So, the documentation should mention that.

Regards