Click to See Complete Forum and Search --> : Viewing threads?


sd9
June 12th, 2009, 12:36 AM
I've just started learning threads and am trying out programs to see how it works.
Using printf statements at parts of the program, I'm getting an idea of how it flows, but I need a better perspective.

Is there a more visual way of seeing how the threads are working? Like...can I see it in a task manager or something?

One more question: why is it that when we compile such a program with -lpthread? Why can't I use the usual g++ -o thread thread.cpp

MrViggy
June 12th, 2009, 01:54 PM
You can view separate threads using a debugger.

The "-l" option to g++ tells it to link in that library. Since you're using pthreads, you need to link with the pthread library (it is not automatically linked in for you).

Viggy

sd9
June 15th, 2009, 01:04 AM
Thank you :)
Tried using the kdbg debugger. The threads window just stayed blank while I ran my program.Guess I'll need another debugger...

MrViggy
June 15th, 2009, 12:25 PM
You can't view anything in a debugger, until you hit a breakpoint. Put a breakpoint in one of your threads, and then check the thread view.

Viggy

sd9
June 24th, 2009, 12:04 AM
You can't view anything in a debugger, until you hit a breakpoint. Put a breakpoint in one of your threads, and then check the thread view.
Viggy
Thanks :) I guess i'll have to figure out more about using the debugger coz I loaded the source code, put in a breakpoint and it seemed like there was no way to run it. Will figure it out soon....