Click here to Skip to main content
15,884,425 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everybody
I am an minerals engineer. I am programming a code for simulating a kind of system. the whole program contains a infinite loop and it will be stopped when I exit my program. In my codes, I am using 3 threads right now. The fist thread just displaying the simulation results, the second thread is saving my simulation results to a text file and the final thread is calculating the system process that I named it Main Simulation Thread (MST).
The MST in each iteration do three tasks that must be performed in queue.
the first task is initialize the system elements, the second task is calculating the elements interaction and the third task is finalizing the iteration results.
Now I want to make my code faster by hiring 8 threads to do the second action of MST (calculating the elements interaction).
It is clear that I have to consider the queue between tasks, so I have to manage the new threads to start when initialize task was done by MST and MST must be stopped when the new threads is doing their job and when the new threads job was finished the MST should do the third task (finalizing the iteration results).
I don't know how to manage these threads.
Please help me.
Posted

1 solution

What you want to do is called thread synchronisation or mutual exclusion depending on details about the scheduling.

This is when a thread have to wait until another thread reach a given point before resuming.

It may get complicated to manage 8 threads with interleaved locking.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900