multithreading doesnt behave itself in tomcat
Hello everyone, greetings this monday morning
I've been working on a web application, and run into a problem which i don't really know where to start with, so i figured i would ask all you veterans (first real job for me) for some advice/help
the situation:
our web app has a pretty pasic MVC structure, one controlling servlet which handles request and calls the bussiness logic, and server the right JSP to the user.
Recently i have added some functions which require iterating over a (potentially) large amount of files and collect all different sorts of statistics. Since the statistics can be roughly divided into three groups, i figured i could use three different Thread classes, one for each type of statistics, so i could take advantage of the fact our production server will be multi-core, thus reducing waiting time for any users calling this function by up to 50% (i could theoretically even scale all the way up to the number of cores on the future server)
now the problem is, in general using this multi threaded approach is slower then calling the threads Run() methods succesively (basically running it single threaded this way) from the main request thread. For some reason my CPU (develloping on a dual core machine) doesnt jump to full load under the multi-threaded code.
At first i theorized that Tomcat simply doesnt allow internal threads for one request to take up more then 1 core in cpu time, but testing revealed that in sometimes (seemingly random) the multi threaded approach is about 10-15% faster then the single threaded version, while at times it can be 30-40% slower
I honestly dont know what to think about this anymore, to me it seems tomcat is messing with the threads
does anyone have any pointers for me?

