DaveShirk's thread about threads (ha ha) has got me thinking. I
haven't actually used a thread for anything in years. What do you use
them for?
Perhaps it's just that I grew up with RB in the far distant past when
threads weren't as reliable as they are now, so I didn't build up a
list of places in my head to use them.
If I need to do long calculations I use a timer with a tiny period
set. Then I find a reasonable amount of time to freeze up the main
thread and save off the start ticks and compare in my loop and when
I've used say, a quarter of a second I bow out and let the main look
process again until the timer is called again and I pick up where I
left off.
Many such things as that.
The things I want to use threads for are exactly the kind of things
you CAN"T use threads for anyway, like having multiple applescript
running at once, or calling out via a declare to do something long
winded. But anything else you can do broken up in the main thread with
similar or better performance than in a thread. Or at least you used
to be able to.
Someone quoted on the list a long time ago something that has stuck
with me ;) Nothing that you do in the computer takes any time at all
until you have to do it more than once. It's only in looping through
large amounts of data or work that things seem to take a long time.
But this is easily handled with timers and loops as above without
halting the main thread.
So what sort of situations do you use threads for?
Thanks,
James
James Sentman http://sentman.com
http://MacHomeAutomation.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|