GhostCat again on strike :
Technical facts based answer: \n\nhaving the loop in your shell script means that you keep constantly starting new JVM processes. That will put a higher load on your system compared to having a loop within the Java program you are executing.\n\nIn other words: you start one JVM session, it does something; it goes down; the next starts ... forever.\n\nProbably Linux is doing a lot of things behind the cover that reduce the cost of doing so (for example by actually keeping things in memory); but still: you are constantly starting processes to end them soon thereafter. \n\nIf you really intend to run your code for an \"infinite\" time; than you definitely want to avoid wasting resources in any form.\n\nThat on the other hand, can give a (weak) argument for keeping the loop on the script side: when you put your loop into your java code, and your java code is actually buggy (memory leaks for example); then the memory consumption of that one JVM could keep growing forever (until reaching its limit; and then you might see a lot of garbage collection). \n\nMeaning: when you know that your Java code is in a bad shape; and that running it in the same JVM over longer periods of time causes problems; then of course: starting and stopping the JVM has some benefits. \nBut of course - in that case, you have some bigger problem anyway. If your java application has such problems, then you better identify their root cause and fix them; instead of constantly starting/stopping your JVM to circumvent these issues.",
2017-01-05T07:37:41