views:

309

answers:

2

When I look in windows task manage it says it's using 3 threads? Why is this? I was expecting just 1 thread to be used.

I used Netbeans IDE and MinGW-Windows g++ to compile it.

Thanks

Code:

#include <iostream>
using namespace std;

int main() {

    cout << "Hello World";

    int input;
    cin >> input;

    return (EXIT_SUCCESS);
}
+6  A: 

Maybe Netbeans put some wrapper for internal purpose ? (debugging, profilling, ...) Anyway it don't matter because you didn't create it : these threads should not interfere with your program and your program will not interfere with them.

William Briand
+1  A: 

I don't use Task Manager or Netbeans, but can I suggest you may have misread the output:

  • one thread to start a shell
  • one thread for the shell to execute your program
  • one thread for your program's executable

Total 3. None except the last have anything to do with C++.

anon
The shell runs as a separate process, not a separate thread.
Billy ONeal
@Billy But we have no idea how the OP is interpreting this information. Using Process Explorer I can interpret the executable as using 5 threads (the total of the process tree), when it is actually (as it always will) only be using one.
anon