Java example: Is this really accessing a static method in a non static way?
<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() + " is tired");

            try{
                Thread.currentThread().sleep(DELAY);
            } catch (InterruptedException e) {}

            System.out.println(getName() + " is rested");
        }
</code></pre>

<p>On line the line with: </p>

<pre><code>Thread.currentThread().sleep(DELAY)
</code></pre>

<p>Eclipse gives a warning: "The static method sleep(long) from the type Thread should be accessed in a static way". 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>

<p>Thanks,</p>

<p>Jeanette</p>
