简体   繁体   中英

PERL parallel multi threading

I am writing a PERL script involving multithreading. It has a GUI and the number of threads to be used will be taken as user input. Depending on this number, the script should generate threads which all access the same sub. I want the n threads to work in parallel. But when I create a loop, the parallel processing is lost. Any idea as to how to overcome this issue?

I believe that the simplest way to answer would be to recommend you to look at something like POE . The framework cookbook webpage provides many examples that surely will be a good starting point for your original issue.

Depending on your GUI platform, you may also want to spend time on event loops provided by the framework itself.

You probably need to call threads->yield() function occasionally in the processing loops. The yield() function gives a "hint" to give up the CPU for a thread.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM