title: How to modify a data structure while a process is already accessing it ?
body: <p>I have written a program (suppose X) in c++ which creates a data structure and then uses it continuously.
  Now I would like to modify that data structure without aborting the previous program.
  I tried 2 ways to accomplish this task :</p>
  
  <ol>
  <li><p>In the same program X, first I created data structure and then tried to create a child process which starts accessing and using that data structure for some purpose. The parent process continues with its execution and asks the user for any modification like insertion, deletion, etc and takes input from console and subsequently modification is done. The problem here is, it doesn't modify the copy of data structure that the child process was using. Later on, I figured out this won't help because the child process is using its own copy of data structure and hence modifications done via parent process won't be reflected in it.  But definitely, I didn't want this to happen. So I went for multithreading. </p></li>
  <li><p>Instead of creating child process, I created an another thread which access that data structure and uses it and tried to take user input from console in different thread. Even, 
  this didn't work because of very fast switching between threads.</p></li>
  </ol>
  
  <p>So, please help me to solve this issue. I want the modification to be reflected in the original data structure. Also I don't want the process (which is accessing and using it continuously) to wait for sometimes since it's time crucial. </p>