processinstancefreeze

Java application freezes when starting from another java application


I have created Java desktop application with some buttons that will just launch different Java applications and scripts. I have one application that is starting fine, but freezes.

App queue increases

When I close the desktop application then the frozen application start working fine and continue loading data.

I´m not sure what could cause application to freeze. Is there a way to start applications as new instance without having any connections to the main desktop tool application?

I did test threading like new Thread(() ->

But, it gave same result. Any help would be appreciated.


Solution

  • Solved:

    Thread t = new Thread(() -> {
    try {
        String filePath = userprofile+"\\OneDrive\\Tools\\pricedash.bat";
        String[] startOptions = new String[] {filePath};
        Process proc = new ProcessBuilder(startOptions).start();
        
        BufferedReader br=new BufferedReader(new InputStreamReader(proc.getInputStream()));
        String line;
        while((line=br.readLine())!=null) {
        } 
    }
    catch (IOException ex) {
        Logger.getLogger(ToolsDesktop.class.getName()).log(Level.SEVERE, null, ex);
    }
        });
    

    t.start();