From: Pete Lewin-H. <pe...@il...> - 2004-09-09 09:15:20
|
Hi, I have discovered a bit of weird behaviour in the id generator factory and was wondering what the reasoning behind may be. Whenever the IDGeneratorFactory.newIDGenerator() method is called, a completely new IDGeneratorImpl object is constructed, which involes a Thread.sleep(100) call being made.In my performance tests, this means that approximately 50% of the time spend in TM4J is spent sleeping which really can't be good! I have rewritten the IDGeneratorFactory and IDGeneratorImpl classes so the Factory stores a singleton IDGenerator object and the Generator returns a random 32 character string (and the getID() method is synchronized). This results in a massive performance benefit and seems to have no impact on anything else. Anyone got any reasons why this is a bad idea? I haven't run the junit tests so I may have missed something vital... cheers, Pete |