Threads & fibers

Nrgyzer nrgyzer at gmail.com
Sun Jan 30 12:33:37 PST 2011


> Nrgyzer <nrgyzer at gmail.com> wrote:
> > The result is: "true" which means that testInstance of type a is
null -
> > but I
> > already created a instance and if I write "writeln(testInstance is
> > null);" after
> > Thread.yield(); in the main, it says "false" which means
testInstance is
> > a valid
> > instance of the class a. -> Why does threadFunc() says true, when
> > testInstance
> > should be a valid instance of a?
> The default storage in D is in TLS, that is, changes in one thread
will
> not be visible to others.
> If instead you mark your class a as 'shared class a', it works the
way
> you'd expect it to.
> > ... is there any chance to interrupt the Thread.sleep-command or
to
> > suspend the
> > thread? As I know, the join()-method does wait until the thread is
> > finished, but
> > does not interrupt the sleep()-command.
> I think the best way to do this would be using std.concurrency, and
> passing it a message. Not sure, though.

Thanks, marking a as shared class works :)... I already used threads
in D1 but there as I just know - since 2.030 I need shared-
decleration.


More information about the Digitalmars-d-learn mailing list