This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ForkJoin only using one core at a time  RSS feed

 
Henry Eck
Greenhorn
Posts: 7
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems that my app has a lot of common memory in use between the tasks/threads, and this is probably the root of the problem that I am seeing. So I am marking this post resolved to avoid wasting anyone's time.

The ForkBlur example has some common memory usage in it as well, and while this is tolerated, it is not optimal. There is some explanation in the Javadoc for class ForkJoinTask.

+++++++++++++++++++++++++

Hi,

I have an application in which I am trying to use the ForkJoin feature, but when I run it, only one core is used at a time. It dutifully creates 4 threads, but only one core is ever in use at a given moment, although it jumps between cores.

System:
Ubuntu 15.0, Dell Inspiron 5548
Netbeans IDE 8.0.2, Java platform JDK1.8

I can run Oracle's ForkBlur.java example:

https://docs.oracle.com/javase/tutorial/essential/concurrency/examples/ForkBlur.java

with no problems - it uses all 4 cpu cores at 100% until finished.

The obvious thing for me to do is to try to pare down the application until the parallelism begins to work right, but it's a large app and that's not so easy, so I would like to ask for advice here: can anyone suggest a reason why this would be happening ?

Thanks very much for any suggestions. Code follows.

Henry Eck



 
Les Morgan
Rancher
Posts: 752
17
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Off of the little bit of code that is there, no, I cannot give you an informed opinion on why your project is not "multitasking as expected".

What I can do is pose a few questions that my help you in your quest to see what is happening:

1 - you do the Oracle example and it works just fine, on the same computer--so lets assume that your JRE and OS are not compromised in some way obscure and bizarre way.
2 - You said the Oracle example was small, so naturally the threads would be assigned and started is short order, but is the processing assigned to each thread in your app long enough to expect to see multiple threads running concurrently--is it logical to expect overlap?
3 - Does the app sufficiently tax your machine so as it cannot free up more than one thread in the thread pool at a time?

Les

BTW: if you have found the reason for your OP, it would be very interesting to see.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!