Singleton implementation with CPP and Java