D and parallel programming
Regan Heath
regan at netmail.co.nz
Tue Aug 7 01:25:58 PDT 2007
Sean Kelly wrote:
> Support for multithreaded programming (what I assume you meant by
> "parallel programming") in D largely amounts to a standard Thread object
> in the library, as well as a "synchronized" keyword which behaves quite
> similar to the one in Java.
Except that (importantly, IMO) it's re-entrant.
By that I mean, if you have:
class Foo
{
int i;
void bar()
{
synchronized(this)
{
i++;
}
}
}
void main()
{
Foo f = new Foo();
synchronized(f)
{
f.bar();
}
}
you get no deadlock. As I believe they do in Java (someone correct me
if I'm wrong).
In short, multiple synchronized blocks, on the same object, in the same
thread are allowed and do not cause a deadlock.
Anyone know what the C# behaviour is in this case?
Regan
More information about the Digitalmars-d
mailing list