-
I understand now. But how can that fit in the example of client/server application. How can the new thread stop the freezing when a client connects to it? Does that new thread handles to connection with the client, and the actuall thread does the other stuff?
-
Threads dont make the app execute faster, but they make it seem that way, by sharing processor time. Using Megatron's analogy, It would be more like you would move two or three apples, then move two or three oranges, and back to the apples again.
As to the question of a server/client app, you could have the server create a new thread to handle each client.
Z.
-
Ohh, I see...Keeping in mind the analogy of Megatron, is that the same way so you can write the text on one part of the screen with one thread, and write another text on the other part of the screen using another thread at EXACTLY the same time?
I know that each process can have different threads and (I think) that each thread allocates its own memory. So, are threads usefull when making large applications?
-
not EXACTLY the same time unless you have multiple proccessors, your OS(windows, usually), does something called timeslicing in which it allocates each thread a certain amount of time to do stuff, before it gives control to another thread, this round-roubin appears to be happening simultainiously. thats why windows is called a preemtive multitasking enviroment. usually, one thread will handle UI(to prevent apparent freezing), and another connecting to the server. on the server side, one thread will be created for each client connection, and then deleted after done. or sometimes programs share a set number of threads, but thats getting complicated
anyways,
-
I fully understand now. Thanks everybody:D