in reply to Thread create hangs

The OP should probably re-consider this entire approach... unless it is just an experiment to see how to do it.   Threads generally can’t meaningfully share resources such as “the terminal,” because of course there is only one of them.   If you are going to spawn multiple threads to do anything at all, be very sure that they will not contend with one another.   A thread should be created for a “purpose” or a “role,” not for a “task” or “request.”

Replies are listed 'Best First'.
Re^2: Thread create hangs
by BrowserUk (Patriarch) on Sep 28, 2010 at 17:50 UTC
    Threads generally can’t meaningfully share resources such as “the terminal,” because of course there is only one of them.

    Twaddle! Forked processes share "the terminal" all the time. Every time you type a piped command those processes are sharing a common console.

    With threads, you have the advantage that coordinating that shared access is trivial. Just a shame about the bug.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: Thread create hangs
by Anonymous Monk on Sep 28, 2010 at 15:06 UTC
    Thanks for replying. I don't think the terminal is being shared among threads in above program. Only main thread is trying to read from terminal. Imagine a situation where you want to create a server where one thread listens for new connections (secondThread in this case) and spawns threads to handle clients (thirdThread in this case), and main thread waits for user's command e.g "exit" to gracefully terminate the server. I understand if there is bug in ActiveState Perl one will have to re-consider the approach otherwise this approach is quite common in real world. thx