My Java program uses java.util.concurrent.Executor to run several threads, each of which runs the runnable class, in this class it reads from a comma-delimited text file on C: drive and goes through lines to separate and parse the text in floats, after which the data is stored in:
static Vector static ConcurrentSkipListMap
My computer is a 7-bit 64-bit Intel Core i7 processor, has six * 2 cores and 24 GB of RAM, I noticed that the program will work for 2 minutes and finish all 1700 files, but the CPU usage is only about 10 % to 15%, no matter how many threads I assign with:
Executor executor=Executors.newFixedThreadPool(50);
Executors.newFixedThreadPool (500) will not have better CPU utilization or reduce task execution time. There is no network traffic, everything is on the local C drive: there is enough RAM to use more threads, with an increase in flows to 1000 it will have the value "OutOfMemoryError".
Why doesn't more threads translate into more CPU usage and less processing time, why?
Edit: My hard drive is a 200GB SSD.
Editing: finally found where the problem is, each thread writes the result to a log file, which is common for all threads, the more times I run the application, the larger the log file, the slower it gets, and since it is common, it definitely slows down the process , so after I stopped writing to the log file, it completes all tasks in 10 seconds!