Data sharing is, as BrowserUK said, easy, and that’s most important in a good threaded design. Your programs won’t bugger up their storage-pool and crash. If you need to share data between threads, simply try to minimize the amount of code that actually contends for shared variables ... within sensible reason. It’s often the case that threads communicate with one another by means of thread-safe queues ... work-to-do lists and work-completed lists. This creates a simple way, not only to reduce contention, but to allow the various threads to work at their own naturally varying speeds. If a particular set of shared variables is frequently and contentiously shared by everyone, they would represent a “hot spot” in any design regardless of language used ... they would tend to cause the threads to be synchronous with one another and to spend too much time waiting on locks, which is not what you want to see. (Maybe the threads could instead include updated values in the messages they return to the work-completed queue.) Obviously, design is a nest of competing trade-offs.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||