java - Timer and timerTask small issue -


i noob @ java. first time use timer , timertask class in java.

purpose of app:

it multi client app implemented mysql. app read database data repeatly. if database updated, want every client's panel updated well. assume need timer class can automatically perform repeating query read database , make change on component of client side.

problem:

i thought tutorial , found way it. since this.updatetablestatus() method in table class, how can use method in mytimer(timertask) class.

public class table extends javax.swing.jframe {      public table() {         initcomponents();         mytimer mytime = new mytimer();      }     public void updatetablestatus(){         // refresh table status reading database data , make change.     }      class mytimer extends timertask{         public mytimer() {             timer timer = new timer();             timer.scheduleatfixedrate(this, new java.util.date(), 1000);         }         public void run(){              this.updatetablestatus();   // not working!!!, because r not in same class.  need solve problem.         }     } } 

help me out guys. thank much.

this.updatetablestatus(); tries reference mytimer's updatetablestatus() method (but there no such method). reference table's updatetablestatus() method, can change

table.this.updatetablestatus(); 

note:
seriously, believe checking db every second each client see if has changed horribly bad app design. suggest post new question, explaining current architecture , requirements, , asking advice how watch db changes efficiently.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -