Threads?

Jarrett Billingsley kb3ctd2 at yahoo.com
Sat Nov 18 13:12:25 PST 2006


"nobody_" <spam at spam.spam> wrote in message 
news:ejns1i$2nnk$1 at digitaldaemon.com...

> Sorry for my late reply (unexpected stuff :(
>
> Won't I get into trouble when I keep everything in one thread and a 
> screen-update takes longer than one millisecond?
> That way I could lose a loop and I really need all 1000 of them at the 
> correct time.

Do you *absolutely* need 1000 updates per second?  What are you doing that 
requires such precise timing?

> I thought that if I were to put the gfx in a different thread I could 
> guarantee my mainloop.
> making the gfx thread idle and having some kind of thread-sleep of 20ms 
> every loop.
>
> Or am I just being naive :)

Keep in mind that even though you're using multiple threads, your code won't 
run any faster.  You've still got the same amount of processing power.  So 
if your logic loop can't keep up with the graphics in a single-threaded 
program, it won't be able to in a multi-threaded program either.  What you'd 
basically end up doing is having the graphics thread wait for the logic 
thread to finish its update, and they'd operate in lock step - at which 
point you're doing pretty much the same thing as having a single-threaded 
program. 





More information about the Digitalmars-d-learn mailing list