title: Making a class Thread-Safe
body: <p>Given:</p>
  
  <pre><code>public class TestSeven extends Thread {
  
  private static int x;
  
  public synchronized void doThings() {
      int current = x;
      current++;
      x = current;
  }
  
  public void run() {
      doThings();
    }
  }
  </code></pre>
  
  <p>Which statement is true?</p>
  
  <p>A. Compilation fails.</p>
  
  <p>B. An exception is thrown at runtime.</p>
  
  <p>C. Synchronizing the run() method would make the class thread-safe.</p>
  
  <p>D. The data in variable "x" are protected from concurrent access problems.</p>
  
  <p>E. Declaring the doThings() method as static would make the class thread-safe.</p>
  
  <p>F. Wrapping the statements within doThings() in a synchronized(new Object()) { } block would make the class thread-safe.</p>
  
  <p>isn't it enough to mark doThings() as synchronized in order to make that class Thread-safe ? i see that the correct answer is D but the Model answer of this question is E, But i don't understand why?</p>