Board index » delphi » Threads Synchronizing Problem
o...@graduate.org
![]() Delphi Developer |
Tue, 08 Aug 2000 03:00:00 GMT
|
o...@graduate.org
![]() Delphi Developer |
Tue, 08 Aug 2000 03:00:00 GMT
Threads Synchronizing ProblemHi, I write some code as following: procedure ThreadDone(sender:TObject); procedure CreateThread; I wonder how i can know that both threads are done in the Any helps are appreciated. Mike, -----== Posted via Deja News, The Leader in Internet Discussion ==----- |
o..
![]() Delphi Developer |
Tue, 08 Aug 2000 03:00:00 GMT
Re:Threads Synchronizing ProblemHi, I write some code as following: procedure ThreadDone(sender:TObject); procedure createthread; I wonder how i can know that both threads are done in the Any helps are appreciated. Mike, -----== Posted via Deja News, The Leader in Internet Discussion ==----- |
Dirk Claessen
![]() Delphi Developer |
Wed, 09 Aug 2000 03:00:00 GMT
Re:Threads Synchronizing Problemo...@graduate.org heeft geschreven in bericht |I write some code as following: It depends on what you want to do. Do you want to restrict the TMyThread.OnTerminate will call the ThreadDone procedure when a thread procedure ThreadDone(sender:TObject); You might do : procedure createthread; with TMyThread.Create(.....) do |
o..
![]() Delphi Developer |
Wed, 09 Aug 2000 03:00:00 GMT
Re:Threads Synchronizing ProblemIn article <6cmbio$lv...@xenon.inbe.net>, Quote
I want "createthread" can wait for all child threads exiting and then exit itself. I tried using CriticalSection and Mutex to do that, but both method seem not to work. It can be: procedure createthread; procedure ThreadDone; It doesn't work because the owner of sect1 is the main thread and it Can you give me any suggestions? Thanks a lot. Mike -----== Posted via Deja News, The Leader in Internet Discussion ==----- |
Dirk Claessen
![]() Delphi Developer |
Thu, 10 Aug 2000 03:00:00 GMT
Re:Threads Synchronizing Problemo...@graduate.org heeft geschreven in bericht [large snip] |> |I wonder how i can know that both threads are done in the Assuming you know beforehand how many child threads you want to start, procedure TMainThread.Execute; Each child should dec() ChildThreadsRunning when it terminates. Hope this puts you on track... Regards, |
Sundial Servic
![]() Delphi Developer |
Thu, 10 Aug 2000 03:00:00 GMT
Re:Threads Synchronizing ProblemQuoteIn article <6cq3f9$oo...@xenon.inbe.net> "Dirk Claessens" <Dirk.Claess...@village.uunet.be> writes: on thread execution behaviors. (1) If "Dec" is not an atomic operation, then there is a miniscule (2) The main-thread is busy-waiting on the other threads, which is burning up (3) A better strategy here would be to use the WaitForMultipleObjects or |
o..
![]() Delphi Developer |
Thu, 10 Aug 2000 03:00:00 GMT
Re:Threads Synchronizing ProblemIn article <6cq3f9$oo...@xenon.inbe.net>, Quote
SYNCHRONIZE() calls in child thread, or else it cause dead lock. BUT I have to synchronize some operation in child thread. And I tried using CriticalSection, Mutex and Semophore, all these have Any additional suggestion? Thanks. Mike -----== Posted via Deja News, The Leader in Internet Discussion ==----- |
Sundial Servic
![]() Delphi Developer |
Thu, 10 Aug 2000 03:00:00 GMT
Re:Threads Synchronizing ProblemQuoteIn article <6cqlo0$5b...@nnrp2.dejanews.com> o...@graduate.org writes: here. It sounds like one of the threads is not releasing the synchronization resource, or the absence of normal message-processing by the main thread is causing a deadlock. Anyway, this is the fundamental problem you have now. Don't overlook the possibility of using a user-defined message, which is |
Dirk Claessen
![]() Delphi Developer |
Sat, 12 Aug 2000 03:00:00 GMT
Re:Threads Synchronizing ProblemSundial Services heeft geschreven in bericht ... Quote<Dirk.Claess...@village.uunet.be> writes: .|>Hope this puts you on track... | | |This might work just fine, Dirk, or it might have serious problems depending |on thread execution behaviors. | |(1) If "Dec" is not an atomic operation, then there is a miniscule |timing-hole -- the classic textbook case -- if the two threads attempt to do |it at the same instant. | I considered Dec() operations to be atomic, being compiled directly |(2) The main-thread is busy-waiting on the other threads, which is agree... |(3) A better strategy here would be to use the Agree again. But I just wanted to keep things simple. :o) It wasn't Bye, Dirk. |
Ray Lischn
![]() Delphi Developer |
Wed, 16 Aug 2000 03:00:00 GMT
Re:Threads Synchronizing ProblemOn Tue, 24 Feb 1998 19:58:58 +0100, "Dirk Claessens" Quote<Dirk.Claess...@village.uunet.be> wrote: operand, for example. -- Ray Lischner (http://www.tempest-sw.com/) Author of "Hidden Paths of Delphi 3: Experts, Wizards, and the Open Tools API" |
Chris Isbe
![]() Delphi Developer |
Thu, 17 Aug 2000 03:00:00 GMT
Re:Threads Synchronizing ProblemQuoten...@junk.mail (Ray Lischner) wrote: processor system, and probably on a multiple processor system). If a page fault occurs during the instruction or the operand fetch, the instruction will not have been executed. A page fault cannot occur during the memory read-modify-write sequence necessary to perform the DEC operation. I would also suspect that a well-designed multi-processor system would not allow other processors to change a memory location during a read-modify-write operation. Am I being dumb and missing something? (This method worked very well when I was implementing semaphores on a -- |
Anders Meland
![]() Delphi Developer |
Tue, 22 Aug 2000 03:00:00 GMT
Re:Threads Synchronizing ProblemQuotech...@isbell.demon.co.uk (Chris Isbell) wrote: Use InterlockedDecrement() and InterlockedIncrement() instead. That's Quote>(This method worked very well when I was implementing semaphores on a Thank you for flying Air Melander. +--------------------from usenet----------------------+ |
1. threads and memos - blocking though synchronized..
2. Non blocking thread "synchronize"?
3. Main Thread reaction to TThread.Synchronize()
4. Dead Lock in Threads Synchronizing
5. threads and memos - blocking though synchronized..
6. Synchronizing Delphi threads: missing primitive?
7. Terminating background thread which uses Synchronize
8. Synchronize method from within Threads