• Post Reply Bookmark Topic Watch Topic
  • New Topic

database and threads java  RSS feed

 
shosana lopez
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm inserting records in the database with the use of threads to monitor the progress of the insertion with the use of progress bar. My program is written in java. Is there a way in which i can stop the thread by clicking a cancel button? i'm getting a nullpointer exception on my conn.createStatement. When i used the interrupt(), my thread just keeps running.... what is the best approach for this?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66158
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clearly not JSP related. Moving to the Threads forum.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your thread is in a loop your cancel button can set some condition that stops the loop:

Read up on the "volatile" keyword which seems to be made just for things like "keepGoing".
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!