java new thread can't call function
Go to solution
Solved by technovore,
magic happened, it works.
dbc is an instance of an object with a public boolean connectionWorks()
private void addDatabaseConnectionThread(){ t = new Thread() { @[member=OverRide] public void run() { while (!interrupted() && threadRunning) { if (dbc.connectionWorks()){ lblDBConnection.setText(""); } else { lblDBConnection.setText("database connection failed"); } try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); } } } }; t.start(); }
don't ask me why this works and the previeous one didn't.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now