Click here to Skip to main content
15,884,905 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Multithreaded code is ridiculous PinPopular
Greg Utas15-Jul-20 11:05
professionalGreg Utas15-Jul-20 11:05 
GeneralRe: Multithreaded code is ridiculous Pin
honey the codewitch15-Jul-20 11:47
mvahoney the codewitch15-Jul-20 11:47 
GeneralRe: Multithreaded code is ridiculous Pin
Greg Utas15-Jul-20 12:22
professionalGreg Utas15-Jul-20 12:22 
GeneralRe: Multithreaded code is ridiculous Pin
honey the codewitch15-Jul-20 12:36
mvahoney the codewitch15-Jul-20 12:36 
GeneralRe: Multithreaded code is ridiculous Pin
Greg Utas15-Jul-20 12:58
professionalGreg Utas15-Jul-20 12:58 
GeneralRe: Multithreaded code is ridiculous Pin
honey the codewitch15-Jul-20 13:16
mvahoney the codewitch15-Jul-20 13:16 
GeneralRe: Multithreaded code is ridiculous Pin
raddevus15-Jul-20 17:29
mvaraddevus15-Jul-20 17:29 
GeneralRe: Multithreaded code is ridiculous Pin
Member 1330167916-Jul-20 20:19
Member 1330167916-Jul-20 20:19 
That isn't the usual way of doing things; the common approach is:

1. Create pool of threads at startup (3, 5, whatever).
2. Create two queues at startup (work-queue and results-queue, using a LL or DLL queue, not an array).
3. Each thread takes the next work item from work-queue, working to completion, and posting the results to results-queue.
4. The main thread simply enqueues work items to the work-queue, and waits on the results-queue (use a semaphore here) for results.

There's no blocking involved other than the wait-on-semaphore (and wait-on-mutex for queue modification).
GeneralRe: Multithreaded code is ridiculous Pin
honey the codewitch17-Jul-20 2:09
mvahoney the codewitch17-Jul-20 2:09 
GeneralRe: Multithreaded code is ridiculous Pin
Member 1330167917-Jul-20 6:28
Member 1330167917-Jul-20 6:28 
GeneralRe: Multithreaded code is ridiculous Pin
achillepaoloni18-Jul-20 7:23
achillepaoloni18-Jul-20 7:23 
GeneralRe: Multithreaded code is ridiculous Pin
raddevus15-Jul-20 17:34
mvaraddevus15-Jul-20 17:34 
GeneralRe: Multithreaded code is ridiculous Pin
Nelek15-Jul-20 22:16
protectorNelek15-Jul-20 22:16 
GeneralRe: Multithreaded code is ridiculous Pin
raddevus16-Jul-20 3:05
mvaraddevus16-Jul-20 3:05 
GeneralRe: Multithreaded code is ridiculous Pin
Greg Utas16-Jul-20 0:37
professionalGreg Utas16-Jul-20 0:37 
GeneralRe: Multithreaded code is ridiculous Pin
CodeWraith15-Jul-20 11:06
CodeWraith15-Jul-20 11:06 
GeneralRe: Multithreaded code is ridiculous Pin
honey the codewitch15-Jul-20 11:56
mvahoney the codewitch15-Jul-20 11:56 
GeneralRe: Multithreaded code is ridiculous Pin
CodeWraith15-Jul-20 12:04
CodeWraith15-Jul-20 12:04 
GeneralRe: Multithreaded code is ridiculous Pin
honey the codewitch15-Jul-20 12:34
mvahoney the codewitch15-Jul-20 12:34 
GeneralRe: Multithreaded code is ridiculous Pin
CodeWraith15-Jul-20 12:47
CodeWraith15-Jul-20 12:47 
GeneralRe: Multithreaded code is ridiculous Pin
PIEBALDconsult15-Jul-20 14:17
mvePIEBALDconsult15-Jul-20 14:17 
GeneralRe: Multithreaded code is ridiculous Pin
honey the codewitch15-Jul-20 14:18
mvahoney the codewitch15-Jul-20 14:18 
GeneralRe: Multithreaded code is ridiculous Pin
PIEBALDconsult15-Jul-20 14:44
mvePIEBALDconsult15-Jul-20 14:44 
GeneralRe: Multithreaded code is ridiculous Pin
honey the codewitch15-Jul-20 15:53
mvahoney the codewitch15-Jul-20 15:53 
GeneralRe: Multithreaded code is ridiculous Pin
Mircea Neacsu15-Jul-20 16:30
Mircea Neacsu15-Jul-20 16:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.