basic concurrency

Frank Benoit keinfarbton at nospam.xyz
Tue Apr 18 07:22:51 PDT 2006


Tydr Schnubbis schrieb:
> If I have an array and want to synchronize all access to it (only one
> thread using it at a time), what's the best way?  I know how to use
> 'synchronized' to make a critical section, but I want to synchronize
> data, not code.

i am not completely sure, but does this make sense?

if you want to access the array consitently, you have to synchronize
multiple accesses.

int[10] a;
a[0] = a[0] +1;
=> how can the data sychronization know that there should be a lock
until the write?

I would write a class, encapsulating the data and all accesses to them.
So you can use the existing thread synchronisation.




More information about the Digitalmars-d-learn mailing list