so I have 2 classes. let's call one Main and one Sub. Main Class
public static boolean variable; public static main(){ variable = false; sub(); while(variable == false){ //pause for 1 millisecond try { TimeUnit.MILLISECONDS.sleep(1); } catch (InterruptedException ex) { Logger.getLogger(mainGUI.class.getName()).log(Level.SEVERE, null, ex); }catch(Exception s){ JOptionPane.showMessageDialog(null, "Unexpected exception:" + s); } } System.out.println("compleate"); } Sub Class
import package.Main; public static sub(){ //wait for 3 seconds try { TimeUnit.MILLISECONDS.sleep(3000); } catch (InterruptedException ex) { Logger.getLogger(mainGUI.class.getName()).log(Level.SEVERE, null, ex); }catch(Exception s){ JOptionPane.showMessageDialog(null, "Unexpected exception:" + s); } Main.varaible = true; } I need a way to edit variables from Sub so that my program can continue.
I have tried the above Sub class but I don't think that works (i have tried testing this, and it didn't work but it was in a big program with a lot going on, so I am not sure that there wasn't another problem)
Subclass code to your question.