🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #9238

Re: Thread and memory

#9238
From: Bob Gonder
Date: Mon, 19 Jul 2004 22:22
48 lines
2434 bytes
Remy Lebeau (TeamB) wrote:
>"Steve Aletto" <steve_alettoANTI@SPAMhotmail.com> wrote in message
>
>
>You are assuming that Sara wants the code to loop.  That may not be the
>actual case.  Looping is not a requirement for threads.

It did sound like she was re-executing the same thread from main.
Past message threads have made it sound like thread destruction isn't
instantanious, that they "hang around" indefinately until MS gets
around to cleaning up. Having a (repetitivly used) thread stay alive
for the duration of the application seems like a simple enough work
around.

Agree Steve's answer may have been a bit short on deatils though.
Perhaps the thread could suspend itself, so main could wake it up to
cycle through again. Or, setting a terminate flag first, wake it up to
self-terminate at program's end. (Again, I don't know details of VCL
or TThread, so just blue-skying)

>> void __fastcall CMyThread::Execute(void)
>> {
>>     while (!Terminated)
>>     {
>>         // Process here

	if( !ThreadTerminate )
		Suspend();
	if( ThreadTerminate )
		break;
>>     }
>> }

main()
{	ThreadTerminate=false;
	thread = new TThread(function,suspended);
	while(app running)
	{
	}
	ThreadTerminate=true;
	thread.Resume();
	WaitForSingleObject( threadID
	delete thread;
}
OnStartThreadButtonClick()
{	thread.Resume()
probably need an interlock so you don't resume a running thread.
}
Technical Details
Message-ID: <f9gof0p2p0eb4h837i0deq9fao9vd2iid6@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40fb3d08@newsgroups.borland.com> <40fbd474@newsgroups.borland.com> <40fbfd3d@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,d35c53850c011fac
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Thread and memory
Date: Mon, 19 Jul 2004 15:22:35 -0700
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <f9gof0p2p0eb4h837i0deq9fao9vd2iid6@4ax.com>
References: <40fb3d08@newsgroups.borland.com> <40fbd474@newsgroups.borland.com> <40fbfd3d@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 65.41.125.111
X-Trace: newsgroups.borland.com 1090275752 65.41.125.111 (19 Jul 2004 15:22:32 -0700)
Lines: 51
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail