title: Object updated by different thread only partially visible for another thread
body: <p>I am doing multi-thread programming and encounter a wired issue: object update is only partially visible for another thread. Here is the pseudo code:</p>
  
  <p>Initial state: thread A is running and thread B is blocked</p>
  
  <pre><code>Class C {
      public int i;
      public String s;
  }
  </code></pre>
  
  <p>Thread A:</p>
  
  <pre><code>...
  // c is an object of class C and is accessible by both thread A and B
  c.i = 10;
  c.s = "success";
  wakeup thread B:
  </code></pre>
  
  <p>Thread B:</p>
  
  <pre><code>// after wakeup
  assert(c.i == 10);
  assert(c.s.equals("success"));
  </code></pre>
  
  <p>The issue is: in thread B, sometimes the value of string c.s actually is null. But I expect it to have the value "success". On the other hand, if I put Thread.sleep(sometime) before the assert statements, then I can see the expected value for c.s. I do not know why it happens.</p>
  
  <p>I tried to declare filed variable s as volatile but it does not help. </p>
  
  <p>Thanks!</p>
  
  <p><strong>Update</strong>
  Thanks for all the replies/answers. After more experiments and investigations, I believe it is a bug of the framework I am using. The framework manages the suspend/resume of threads and it runs into messy when there are many concurrent requests/connections (like 10k threads).</p>