public void Send(Packet packet)
{
lock (this)
{
Console.WriteLine("packet send start... thread - {0}", Thread.CurrentThread.ManagedThreadId);
this.Send(buffer, 0, buffer.Length, SocketFlags.None, out this.error);
Console.WriteLine("packet send end... thread - {0}", Thread.CurrentThread.ManagedThreadId);
}
}
c#에서 thread-safe 한 함수를 만들려고 이런식으로 lock을 사용해서 함수를 만들어놨거든?
평소에는 로그가 이렇게 나와
packet send start... thread - 26
packet send end... thread - 26
packet send start... thread - 26
packet send end... thread - 26
그런데 가끔씩
packet send start... thread - 17
packet send start... thread - 29
이렇게 나오거든..?
분명 lock으로 감쌋는데 왜 lock을 뚫고 또다른 쓰레드가 진입할 수 있는거지?
이거 c#의 버그인가?
스택메모리가꽉차면 다른주소를 지정해주는게아닐까?
언어에 버그가 어디씁니까... 컴파일러나 os에서 우리가 모르는 어떤 작업을 하겠져
언어라고 왜 버그가 없음? cpu도 버그가 있는판에.. 이거 왠지 마이크로소프트에 보내서 버그신고 해야할거 같네..
this 말고 딴걸로 잠궈봐
private static 인 무언가로 잠그든지. 이건 보나 마나 논리적인 문제임.
영어에는 버그 같은거 업나여
구글한번이면나오는걸