java - Managing thread from a mouseclick -
may basic question. i'm little confused it. in design i've thread started mouse click. method looks this: runnable r = new runnable(){ public void run(){ a.firstmethod(); a.secondmethod(); b.firstmethod(); b.secondmethod(); b.thirdmethod(); } }; new thread(r).start(); here b.firstmethod(), b.secondmethod(), b.thirdmethod(); accessing same variables , database operations during execution (i.e. locking, reading, writing etc.). but, if mouse clicked during execution or before finishing tasks error message database. how can handle such type of situations. here cannot force user wait simple progressbar. to handle such situation, can disable button once thread has started execution, , enable again once thread going finish execution. code following: runnable r = new runnable() { public void run() { button.setenabled(false); a.firstmethod(); a.secondmethod(); b.firstmethod(); b.secondmethod(); b.thirdmethod(); button.setenabled(tr...