singleton java/c++