Mark, since each of your thread runs a TestThread which implements runnable, those thread do not access the field or method of other threads, I do not think the test is multi-threaded. You could use one or two your BenchmarkTest class, and let more than more thread access its method instead.
2009/6/18 Mark Thomas <ma...@apache.org> > Konstantin Kolinko wrote: > > 2009/6/18 <ma...@apache.org>: > >> Author: markt > >> Date: Thu Jun 18 08:32:29 2009 > >> New Revision: 785952 > >> > >> URL: http://svn.apache.org/viewvc?rev=785952&view=rev > >> Log: > >> Add some micro-benchmarks that enable the differences between the Sync > and ThreadLocal approach to be compared > >> > >> Added: > >> tomcat/trunk/test/org/apache/catalina/valves/ > >> tomcat/trunk/test/org/apache/catalina/valves/Benchmarks.java > >> > >> (...) > >> + private ThreadLocal<SimpleDateFormat> yearFormatterLocal = > >> + new ThreadLocal<SimpleDateFormat>() { > >> + protected SimpleDateFormat initialValue() { > >> + return new SimpleDateFormat("yyyy"); > >> + } > >> + }; > >> + private ThreadLocal<SimpleDateFormat> timeFormatterLocal = > >> + new ThreadLocal<SimpleDateFormat>() { > >> + protected SimpleDateFormat initialValue() { > >> + return new SimpleDateFormat("hh:mm:ss"); > >> + } > >> + }; > >> + > > > > I wonder, > > may be we can have a single ThreadLocal that holds some object > > that stores all the formatters (maybe with lazy initialization), > > instead of wrapping each one individually? > > > > Will it make some difference? > > Don't know. You could always add your own test to the benchmarks and find > out :) > > Mark > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org > For additional commands, e-mail: dev-h...@tomcat.apache.org > > -- Sincerely yours and Best Regards, Xie Xiaodong