user1703096
user1703096

Reputation: 115

Java 7 forking and joining

I have a main thread from which I want to spawn 2 threads to parse two different xml's. I want to know if Java 7 fork-join should be used in this scenario or the traditional way that is how we used to do in jdk 1.4 enough for this case?

Upvotes: 0

Views: 146

Answers (1)

Jk1
Jk1

Reputation: 11443

Fork/Join Framework is great is you have a potential tree of task and the size of this tree is unknown. Merge sort is a good example here. Having, however, only two files to parse you won't be able to utilize the key features of FJF:

  • Work stealing - a dynamic balancing of task queues for working threads
  • Easy scheduling for new tasks spawning by existing ones

You may, of course, implement it using FJF to play with nice new classes and it will do the trick. But you're unlikely to get any performance or maintainability benefits out of it, so my recomendation would be to follow a traditional approach here.

Upvotes: 1

Related Questions