2

I've been asked to convert an application (relatively small one) from Python to Java since all the machines in adjacent branches have Java but not Python (and no .exe generator).

The gist of the application is a map that displays lines or polygons based on a variety of user chosen calculations. There is very minimal I/O in the program (at this state) and that which exists sits on a separate thread from the GUI. Currently the calculations are handled via multiprocessing, as there may be as many as 15 "packages" containing 10,000 calculations. Our systems have 32 cores (16 + 16 HTT) and the program was successfully implemented using a method similar to the first answer on this SO post. Essentially, each "package" is put into its own process and a Queue shares the results and the GUI updates.

My Java experience is all CLI based; I've messed around with some sample GUI's (making a button and what have you) but nothing nearly this complex. However, from the SO searching and Google results, it doesnt appear that multiprocessing would be the way to go. In fact, most answers say that multithreading is the way to go. Now, I believe this is where my Python-isms cause me a problem, as in Python the GIL prevents concurrent threads from executing (unless one starts using async implementations) and thus I switch to multiprocessing. I should note that the calculations require little overhead even when using 15 individual cores via the pool.map() method in Python; this implementation was chosen solely for concurrent CPU bound work.

Is my understanding of Python threading (and the terror that is the GIL) causing me unnecessary confusion in Java-land? Do Java threads run concurrently and there is no reason to say pull out 15 ProcessBuilders and run the JVM 15 times on a machine? I'm hoping not, thats a lot of resources!

pstatix
  • 3,611
  • 4
  • 18
  • 40
  • The JVM does not have a GIL. – juanpa.arrivillaga Jan 02 '18 at 21:51
  • @juanpa.arrivillaga So Java threads are able to run concurrently under the same process using the underlying OS thread mechanics? – pstatix Jan 02 '18 at 21:52
  • Yes. I don't have much experience with concurrency in Java, but I suspect that Java 8 parallel streams will allow for a straightforward translation of your `pool.map` implementation. As an aside, if by `async` you mean coroutine function definitions, these don't avoid the GIL. – juanpa.arrivillaga Jan 02 '18 at 21:56
  • @juanpa.arrivillaga Do they not (in reference to `async`)? Limited use with them, was always told they do. I've got a developer to chastise now. – pstatix Jan 02 '18 at 21:58

0 Answers0