This of course doesn't include the time to search the cache which shouldn't be that high. On the other hand, if the document is not found in the cache then it will assign a key to it and put it in the cache for later retrieval. Using multiple threads in a program means that at any instant the program has multiple points of execution. A thread is a lightweight process. That is the creation and destruction of threads is done cheaply.
Threads are very useful when writing servers capable of serving multiple clients.
Qusay H. Mahmoud is a Software Designer for a major telecommunications company in Ottawa, Canada. He holds a B.Sc. in Data Analysis, and a Masters degree in Computer Science, both from the University of New Brunswick, Canada. All rights reserved.