a Simple example public IDPruduce{ private int newID; private static IDPruduce instance=null; private IDPruduce{ //get a value to start newID=0;} //get the only one object of IDPruduce public synchronized static IDPruduce getInstance(){ instance=new IDPruduce() ; } //get id public synchronized int getNewID{ newID++; return newID; }
public IDPruduce{
private int newID;
private static IDPruduce instance=null;
private IDPruduce{
//get a value to start
newID=0;}
//get the only one object of IDPruduce
public synchronized static IDPruduce getInstance(){
instance=new IDPruduce() ;
}
//get id
public synchronized int getNewID{
newID++;
return newID;
}