How to use core.thread.Thread

aki via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 17 00:56:46 PDT 2015


On Thursday, 16 July 2015 at 09:17:47 UTC, Daniel Kozák wrote:
> class DerivedThread : Thread {
>     shared int count = 0;
> }

I thought shared is only for whole of the object.
     auto thr = new DerivedThread();
Here, "thr" is not shared but it's member thr.count is shared?
But if it's not shared, thr object referred by main thread and
"this" reference of DerivedThread.run() are different?
What happen if there are both shared and unshared member exists?

class DerivedThread : Thread {
     shared int count = 0;
     int foo = 0;
}

Umm. I can't imagine what's the memory layout of this object.



More information about the Digitalmars-d-learn mailing list