title: Multithreading in WebAssembly
body: <p>I will be grateful if you answer my question about WebAssembly multithreading.
  I want to implement code with 2 threads (the main thread and a helper one), such that there is a global variable that is used as a counter variable in the helper thread and it increments it in a loop. and the main thread, read the counter variable amount, once before running instruction and once after that (to measure the time that takes for this instruction to be completed).
  I have implemented this code:</p>
  
  <hr>
  
  <pre><code>#include "pthread.h"
  #include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  #include&lt;chrono&gt;
  
  int i;
  int counter;
  
  void* timerfunction( void *ptr)
  {
    printf ("Thread Timer!\n");
    //cout&lt;&lt;"Thread Timer!"&lt;&lt;endl;
    while(1)
    {
      counter=counter+1;
    }
    pthread_exit("The thread was exited!");
  }
  
  
  
  
  int main()
  {
      pthread_t thread_id;
      void *thread_result;
      int c=0;
      int l=pthread_create(&amp;thread_id,NULL,timerfunction,&amp;c);
      int t1= counter;//reading the counter for the first one
  
      //intended instruction that we want to measure its execution time   
  
      int t2= counter;//reading the counter for the second one
      int t3 = t2 - t1;//computing the time
      printf ("value in the counter is: %d \n", t3);
      return 0;
  }
  </code></pre>
  
  <p>What I comprehended is that the supporting of Wasm from multithreading is not complete, because it does not run the main thread and other ones simultaneously and it needs something like sleep to switch between threads. So we cannot use multithreaded Wasm for some goals like increasing a counter in one thread and reading it simultaneously in another one. My question is that either my inference is true or not? And if true, what is the problem? From C or compile process or ...? And is there any alternative method for using complete multithreading?
  Thanks a lot.</p>