Unable to enter critical section
Why is it imposible to enter critical section without Sleep(1)? type TMyThread = class(TThread) public procedure Execute; override; end; var T: TMyThread; c: TRTLCriticalSection; implementation procedure TForm1.FormCreate(Sender: TObject); begin InitializeCriticalSection(c); T := TMyThread.Create(false); end; procedure TMyThread.Execute; begin repeat EnterCriticalSection(c); Sleep(100); LeaveCriticalSection(c); sleep(1); // can't enter from another thread without it until false; end; procedure TForm1.Button1Click(Sender: TObject); begin EnterCriticalSection(c); Caption := 'entered';