vishi has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks, I have written some code where I am using threads - 4 threads to be precise. I am printing some stuff in all these threads and as expected, when I execute the program, all print statements are coming up one after the other. This is fine as long as I am printing output.
However, I also need to get inputs from users across all 4 threads. Because these input prompts (and print statements) come up at almost the same time, the user is confused as to what input (s)he is trying to enter... and most of the times, the wrong input is entered because of this "mass" of text on the screen.
To give you an idea what my screen looks like, see this:
T1-Enter Option: T3-Would you like to continue (y/n): T2-T4Press any k +ey to exit-Please choose an item from the menu:
Basically, its printing everything in one shot. I tried using newlines, etc. to separate these input prompts, but it didn't help much.
Here's my question: Is there any way we can have the screen clear & refresh every N seconds and each time it refreshes, it prints the stuff relevant to one thread only? This way, I am doing a cyclic refresh of screens where each thread displays only its input prompt during its' N seconds of display - and after input has been given, each thread continues to show the execution results / print statements relevant to its own context.
So here's what my program would look like when print statements and input prompts are displayed one after the other
Screen1/Thread1:T1-Enter Option: [wait 10s ]
Screen2/Thread2:T2-Press any key to exit [wait 10s]
Screen3/Thread3:T3-Would you like to continue (y/n):[wait 10s]
Screen4/Thread4:T4-Please choose an item from the menu:[wait 10s]
...
...
...
...
keep rotating these screens until the program / threads finish their work...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Controlling display of print command
by Corion (Patriarch) on Apr 03, 2011 at 08:51 UTC | |
by vishi (Beadle) on Apr 05, 2011 at 07:53 UTC | |
by Corion (Patriarch) on Apr 05, 2011 at 09:52 UTC |