class SingleDemo
{
public static void main(String[] args)
{
for(int i=1;i<10;i++)
{
Thread t1 = new Test();
t1.start();
}
}
}
class Test extends Thread
{
public void run()
{
Single single = Single.getInstance();
System.out.println(this.getName() + " getInstance:"+single);
}
}
class Single
{
private static final Single SINGLE = new Single();
private Single(){}
public static Single getInstance()
{
return SINGLE;
}
}
{
public static void main(String[] args)
{
for(int i=1;i<10;i++)
{
Thread t1 = new Test();
t1.start();
}
}
}
class Test extends Thread
{
public void run()
{
Single single = Single.getInstance();
System.out.println(this.getName() + " getInstance:"+single);
}
}
class Single
{
private static final Single SINGLE = new Single();
private Single(){}
public static Single getInstance()
{
return SINGLE;
}
}