[error] The nested type cannot hide an enclosing type [message #746510] |
Sun, 23 October 2011 09:46  |
Eclipse User |
|
|
|
package javabeat.samples;
public class VolatileExample {
class ExampleThread extends Thread {
private volatile int testValue;
public ExampleThread(String str){
super(str);
}
public void run() {
for (int i = 0; i < 3; i++) {
try {
System.out.println(getName() + " : "+i);
if (getName().equals("Thread 1 "))
{
testValue = 10;
}
if (getName().equals("Thread 2 "))
{
System.out.println( "Test Value : " + testValue);
}
Thread.sleep(1000);
} catch (InterruptedException exception) {
exception.printStackTrace();
}
}
}
}
public class VolatileExample {
public static void main(String args[]) {
new ExampleThread("Thread 1 ").start();
new ExampleThread("Thread 2 ").start();
}
}
}
Sourced from http://www.javabeat.net/tips/169-volatile-keyword-in-java.html.
Error message: The nested type VolatileExample cannot hide an enclosing type
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.08395 seconds