title: IF and assignment statement are Thread safe
body: <pre><code>private LinkedList&lt;Integer&gt; list = new LinkedList&lt;Integer&gt;();
  private synchronized int foo(int x){
      if(x&gt;=0){ //do something
          list.add(x);
          return x    }
      else {
  
          int tmp = list.removeFirst();
          return tmp;
      }
  
      return -1;
  }
  public void test(int id)
  {
      if(foo(id)==-1)
          //do something
          }
  
  public void test2(int id){
      int y=foo(id);
      System.out.println(id+" "+ y);
  }
  </code></pre>
  
  <p>if the test and test2 method has been accessed by multiple threads is thread-safe meanwhile test and test2 are not declared synchronized?
  Ps sorry i correct the code</p>