my $thr = threads->new( \&worker, ... );
Do, (temporarily) worker( ... );
Threaded programmers rule 1: When you've sorted out the bugs in your code when running it single threaded, it is an awful lot easier to get it to run multi-threaded.
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.
| [reply] [d/l] [select] |
| [reply] |
| [reply] [d/l] |
This is, actually, sensible advice. First, get the program working correctly in a single thread. Then, get the multithreading logic to work (i.e. threads are launched and terminated correctly), perhaps using dummy logic within those threads. Only then do you try to put the two pieces together. (And when you do so, start with “only one thread,” which makes it almost-the-same as the first problem that you’ve already dealt with and solved.)
When dealing with complex problems, especially ones that have a timing-sensitive element as all threaded programs do, you must reduce the overall problem into a set of smaller ones that you can address individually. Or, as one of my colleagues put it, “always cross the stream one rock at a time, and try to keep your boots dry as you do it.”
| |
I thought the advice was "Don't cross the streams!"
Same idea, however: keep everything independent as long as possible.
| [reply] |
| [reply] |