|
From: Shaddow <Sh...@ti...> - 2001-02-27 00:07:32
|
Simon R Hillman wrote: > Hi > > Can anyone please explain to me what C threads are? > > Cheers > > ---------------------- > Simon R Hillman > sim...@kc... Hiya Simon, Threads are essentially separate sequences of execution within a program that (at least at a high level conceptually) can be operating at the same time. In a more "traditional" program, for example, if you wanted to read information to a file and display something else on the screen, you had to do them one after the other. Either you read from the file and then do the screen display or the other way around. This is because a "traditional" kind of programming paradigm had a single "thread of execution" in the program... Only one thing can happen at a time. With a multi-threaded application however, your program can do (again, at least at a high level conceptually since a single processor can only do one thing at a time) several things at the same time. You can, in essence, start one thread and tell it to do the file manipulation while another thread does the screen display. Think of this as the application level equivalent of an operating system that permits multiple users work at the same time. What multi-threading tricky is that the individual threads in a given application all operate on the same process space... meaning that they all share a significant resources. Thus, each thread has equal access to global variables, static class members etc... Brian |