xxxxxxxxxx
import core.thread;
import std.stdio;
class SuperUsefulThing
{
private int _value;
this() { _value = 0; }
int read() { return _value; }
void write(int value) { _value = value; }
}
void main()
{
class OtherThread : Thread
{
private SuperUsefulThing _object;
this(SuperUsefulThing object)
{
super(&run);
_object = object;
}
private void run()
{
_object.read();
_object.write(1234);
}
}
auto myNotSharedObject = new SuperUsefulThing();
myNotSharedObject.write(7);
auto ot = new OtherThread(myNotSharedObject).start();
ot.join();
writeln(myNotSharedObject.read());
}