Hello,

I have a console application and am using CreateThread to create a new
thread from my main thread. Both threads call printf and, thus, cause
interleaved prints to the console window. Is there a reasonable way to have
the second thread open it's own console window and direct its printfs to
that window? I can't separate them into two separate applications because
they must share common global variables.

Thanks,
Ray Mitchell
RayMitchell@MeanOldTeacher.com

Re: printf in a multi-threaded console application by ak

ak
Fri Feb 06 05:15:01 CST 2004

On Fri, 06 Feb 2004 10:25:37 GMT, "Ray Mitchell"
<RayMitchell@MeanOldTeacher.com> wrote:

//Hello,
//
//I have a console application and am using CreateThread to create a new
//thread from my main thread. Both threads call printf and, thus, cause
//interleaved prints to the console window. Is there a reasonable way to have
//the second thread open it's own console window and direct its printfs to
//that window? I can't separate them into two separate applications because
//they must share common global variables.
//
//Thanks,
//Ray Mitchell
//RayMitchell@MeanOldTeacher.com
//
//

first of all use _beginthread instead since
CreateThread doesnt support the c-runtime library.

sure you can open as many windows as you want,
rtfm :p

hth
/ak

Re: printf in a multi-threaded console application by Mathew

Mathew
Fri Feb 06 06:27:16 CST 2004

To print it properly, use a synchronizing kernel object such as mutex.

--
Regards,
Mathew Joy



Re: printf in a multi-threaded console application by Igor

Igor
Fri Feb 06 11:54:23 CST 2004

"Ray Mitchell" <RayMitchell@MeanOldTeacher.com> wrote in message
news:BYJUb.13488$F23.1148@newsread2.news.pas.earthlink.net...
> I have a console application and am using CreateThread to create a new
> thread from my main thread. Both threads call printf and, thus, cause
> interleaved prints to the console window. Is there a reasonable way
to have
> the second thread open it's own console window and direct its printfs
to
> that window?

No, a single process can only have one console.
--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken



Re: printf in a multi-threaded console application by Jonathan

Jonathan
Sun Feb 08 20:36:54 CST 2004


"ak" <ak@workmail.com> wrote in message
news:pmt620pp8t74hp7cen540j4j3uh6rj2ki2@4ax.com...
> On Fri, 06 Feb 2004 10:25:37 GMT, "Ray Mitchell"
> <RayMitchell@MeanOldTeacher.com> wrote:
>
> //Hello,
> //
> //I have a console application and am using CreateThread to create a new
> //thread from my main thread. Both threads call printf and, thus, cause
> //interleaved prints to the console window. Is there a reasonable way to
have
> //the second thread open it's own console window and direct its printfs to
> //that window? I can't separate them into two separate applications
because
> //they must share common global variables.
> //
> //Thanks,
> //Ray Mitchell
> //RayMitchell@MeanOldTeacher.com
> //
> //
>
> first of all use _beginthread instead since
> CreateThread doesnt support the c-runtime library.
>
> sure you can open as many windows as you want,
> rtfm :p
>
> hth
> /ak

Someone needs to read a little more carefully. The OP asked about opening a
second *console* window. A process can only have one console.