Making threads in C++ vs. Two Separate Programs?
I'm making an application that receives user input while it is searching for the requested info in C开发者_JAVA技巧++. Would it be better just to run two different applications in Windows Explorer? Would it be faster?
What you describe sounds like the typical use case for multi-threaded programming. You would have your main thread waiting for user input and start up additional threads to do other things like searching.
The other approach of designing two separate processes that will have to communicate and coordinate between each other will add some additional overhead. So speed-wise you might benefit only if there's little back-and-forth communication required.
The answer depends on several factors, such as how much time does all this process take, and how much information should the two processes share between them.
If this is a matter of seconds, and there is a data structure shared between the two parts of your application, I don't see any point in separating them into distinct processes. It's much easier to share memory between threads (just don't forget to use thread-safe data structures).
精彩评论