The Mosquito ScriptKiddiot wrote: > i cant understand the idea of different threads within a process...i understand > what a process is, but i cant make any sense of 'multiple threads' within a > process > > a book im reading says that if u had a process that needed to read in data from > a disk, process it, and then output the result back to sum other file on disk, > you could have three different threads (instead of just one thread performing > all three tasks), one for constantly taking in data, one for constantly > processing and outputting to a buffer, and another for constantly writing that > to disk...and this would sumhow be 'parallelism'...so it would be faster...but > on a single processor comp, wouldnt it be impossible to do all three at once, > so in effect, it would just really be like one thread??! whats the idea of > different threads? Very practicaly, building on multiple threads makes your program easier to code. If faster or not mainly depends on your OS, that is a smart OS will give more cycles to the thread that needs them, so threads of the process that idle are not wasting cycles. If you want a practical example of the matter, try comparing Windows 95 and 98. > and where can i find example of code that clearly shows > which part of the code would constitute a separate thread? (even pseudo-code > would help) Ahem, the simplest way to put it, in Visual Basic, separate timers form seperate threads, where the priority of each thread is defined by it's interval. A timer is an object that executes it's code each time the OS gives it a chance. A 1000 ms interval will give the timer such priority that the OS should give it a chance to execute it's code once every second. Should. Practicaly, if you have a program with an engine and a GUI seperate (recomended), you'll want to run each in a seperate thread. You would be giving the engine a little higher priority than the GUI drawing code, to maximize preformance. Debugging note: Things can get interesting when you add a codeblock into your timer, that instructs the OS to find another thread to execute (required in longer procedures in an OS like Windows 95, unless you want to loose the GUI every once in a while). Have you given your timer a very high priority (such as 1 ms for example), the OS will run the same thread again and you will end up with ~10 copies of the same thread running at once, which is likely to cause migranes at least. Something you'll want to avoid. -- Observer aka DustWolf aka CyberLegend aka Jure Sah C'ya! -- Cellphone: 0038640809676 (SMS enabled) Don't feel bad about asking/telling me anything, I will always gladly reply. [AC/HFA(AS) -- no suprize] The perfect package for online business, ICI: http://www.aimetasearch.com/ici/index.htm MesonAI -- If nobody else wants to do it, why shouldn't we?(TM)