🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Calling Sleep function from an application multithread

#14324
From: Colin Maharaj
Date: Fri, 15 Aug 2003 23:45
28 lines
1997 bytes
Antonio Farfan wrote:
> 
> I suppose that a call to function Sleep in an application multihread from a
> thread could generate that this thread is not wake up by the Scheduler of
> o.s.
> My ask is if there are any call more safe that this sleep.
> 
> Thanks very much

Hi Antonio,
Firstly,
Sleep is always a good function to use in a Threaded function especially
if the function 
is looping in a while or do/while statement construction.

Secondly,
It is better that the thread is signaled so that there is no continous
task switching caused by Sleep()
which is usually an expensive process (i.e. takes up lots of CPU cycles)
especially 
on a single CPU machine.

Thirdly,
If the thread is at normal Priority and not Idle, chances are your
thread will re-enter 
just when the Sleep time has expired, unless there is another thread
that is taking up tonnes 
of CPU resources somewhere with higher Priority.
Technical Details
Message-ID: <3F3D7087.5851A684@cablenett.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!newsfeed.gamma.ru!Gamma.RU!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3f3bb174@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,cae0500b27212399
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-08-15 17:02:08 PST
Message-ID: <3F3D7087.5851A684@cablenett.net>
Date: Fri, 15 Aug 2003 19:45:11 -0400
From: Colin Maharaj <cbm@cablenett.net>
Reply-To: cbm@cablenett.net
X-Mailer: Mozilla 4.78 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Calling Sleep function from an application multithread
References: <3f3bb174@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 196.32.37.66
X-Trace: newsgroups.borland.com 1060991176 196.32.37.66 (15 Aug 2003 16:46:16 -0700)
Lines: 28
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-09!supernews.com!newsfeed.gamma.ru!Gamma.RU!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail