in reply to Re: Weird Output with Threads and NCurses
in thread Weird Output with Threads and NCurses

Thanks for the wordy post , I understood the issue better now. Do we need threads If we serialize a move operation ? We can achieve the similar behaviour with a simple code below,
@positions = qw/5 15/; while (1) { for (@positions) { move($_, CONSTANT); addstr($Counter); $Counter++; } }
But the  $Counter is same and we will have to write little complex code to use multiple counters. Then where do we really use threads in GUI Applications ?

Replies are listed 'Best First'.
Re^3: Weird Output with Threads and NCurses
by soonix (Chancellor) on Jul 18, 2016 at 11:18 UTC
    where do we really use threads in GUI Applications ?

    behind the curtain

    That is to say, when the GUI receives a key or button press from the user, it hands the (possibly lengthy) action off to a "background" thread, so that meanwhile the user can immediately prepare (and initiate) the next action without having to gnaw fingernails or knuckles :-)
Re^3: Weird Output with Threads and NCurses
by Marshall (Canon) on Jul 19, 2016 at 15:28 UTC
    Not using threads at all is certainly one of the options. The code that you have looks fine to me. There could wind up with the need for a worker thread to do something and that is fine as long as it is not talking directly to the gui. Glad to hear that you understand the issue now.