Autor Beitrag
c#surfer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 42
Erhaltene Danke: 2



BeitragVerfasst: Mo 15.02.10 13:29 
Hallo,

in der MSDN Hilfe zur Queue<T>-Klasse wird folgendes gesagt:
Zitat:
Threadsicherheit
Öffentliche statische Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Nun habe ich mir als Beispiel Dequeue im Reflector angeschaut:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
public T Dequeue()
{
    if (this._size == 0)
    {
        ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_EmptyQueue);
    }
    T local = this._array[this._head];
    this._array[this._head] = default(T);
    this._head = (this._head + 1) % this._array.Length;
    this._size--;
    this._version++;
    return local;
}

Wie wird hiermit die Threadsicherheit gewährleistet? Es gibt kein lock oder ähnliches...
Was übersehe ich hier?

Danke
c#surfer
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 15.02.10 13:41 
Nein, aber das ist ja auch kein statischer Member, sondern ein Instanzmember.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
c#surfer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 42
Erhaltene Danke: 2



BeitragVerfasst: Mo 15.02.10 15:34 
Du hast natürlich völlig Recht. Ich hatte den Satz über die Threadsicherheit nicht gründlich genug gelesen. Danke für den Hinweis.