title: Java example: Is this really accessing a static method in a non-static way?
body: <p>I am just working through some examples from my text book, writing the code in Eclipse to figure it out.</p>
  <p>This is the code for the method I have a question about:</p>
  <pre><code>public void run() {
      //Get the lock before entering the loop
      synchronized(getClass()) {
          for (int i =0; i&lt;N; i++) {
              System.out.println(getName() + &quot; is tired&quot;);
              
              try{
                  Thread.currentThread().sleep(DELAY);
              } catch (InterruptedException e) {}
              
              System.out.println(getName() + &quot; is rested&quot;);
          }
  </code></pre>
  <p>On line the line with:</p>
  <pre><code>Thread.currentThread().sleep(DELAY)
  </code></pre>
  <p>Eclipse gives a warning: &quot;The static method sleep(long) from the type Thread should be accessed in a static way&quot;. Eclipse suggests the following solution:</p>
  <pre><code>Thread.currentThread();
  Thread.sleep(DELAY);
  </code></pre>
  <p>I don't understand why it makes a difference (if it really does). Can someone please explain?</p>