Y
yhl1118
Unregistered / Unconfirmed
GUEST, unregistred user!
我定义了两个TRTLCriticalSection,在线程中使用<br>var<br> g_RTLCriticalSection_1, g_RTLCriticalSection_2 : TRTLCriticalSection;<br> g_count_1, g_count_2 : integer;<br>//1.由于程序总出现问题,所以想确定一下是不是这种写?<br>procedure TMyThread.Execute;<br>begin<br> EnterCriticalSection(g_RTLCriticalSection_1);<br> inc(g_count_1);<br> LeaveCriticalSection(g_RTLCriticalSection_1);<br>end;<br>//2.能否在一个TRTLCriticalSection中使用另一个TRTLCriticalSection<br>EnterCriticalSection(g_RTLCriticalSection_1);<br>inc(g_count_1);<br>EnterCriticalSection(g_RTLCriticalSection_2);<br>inc(g_count_2);<br>LeaveCriticalSection(g_RTLCriticalSection_2);<br>LeaveCriticalSection(g_RTLCriticalSection_1);<br><br>请指点一下,谢谢!