Analysis and Optimization of Task Granularity on the Java Virtual Machine