Skip to main content

[Migrated content. Thread originally posted on 02 February 2004]

Am I misunderstanding the way threads work?

Here is something I tried and it didn't work the way I expected.

I have an initial graphical window displayed and in it I display a 01 level screen section entry containing graphical controls.

When a button is clicked, I execute a PERFORM IN THREAD to create a new thread.

In running in the new thread, I display a modeless floating window with BIND TO THREAD specified. Then in that thread, I display the same 01 level screen section entry I displayed in the initial window, which I want to appear in the new window. But it doesn't - it redisplays in the initial window. I also tried using DISPLAY .. UPON using the window handle of the second window and that did not work.

From that, is it correct that I cannot display/accept the same screen section entry in multiple windows in the same program?

[Migrated content. Thread originally posted on 02 February 2004]

Am I misunderstanding the way threads work?

Here is something I tried and it didn't work the way I expected.

I have an initial graphical window displayed and in it I display a 01 level screen section entry containing graphical controls.

When a button is clicked, I execute a PERFORM IN THREAD to create a new thread.

In running in the new thread, I display a modeless floating window with BIND TO THREAD specified. Then in that thread, I display the same 01 level screen section entry I displayed in the initial window, which I want to appear in the new window. But it doesn't - it redisplays in the initial window. I also tried using DISPLAY .. UPON using the window handle of the second window and that did not work.

From that, is it correct that I cannot display/accept the same screen section entry in multiple windows in the same program?
Correct, if you have a screen section item ABC in the same program, you cannot display this twice within the same program even though you execute a paragraph or a section in separate threads. This because the COBOL language has no mechanism for thread safe variables.

This is however using the approach you've chosen. If you separate out the screen section part into an individual application, you can call this application like:

call IN THREAD "mysubprog" HANDLE in mythreadhandle.

And then, inside this, you allocate your sub window and do a DISPLAY screenitem UPON mysubwindow, you should be able to do what you want.