• Post Reply Bookmark Topic Watch Topic
  • New Topic

Pausing a thread  RSS feed

 
Andrew Ceronoski
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know of a better way to pause a thread besides ".pleasesuspend = true;" and



Ive tried notify and wait...but it eclipse says "Unhandled exception type InterruptedException" when I enter it.

Any help would be greatly appreciated! This is really an annoying bug!
 
Rob Spoor
Sheriff
Posts: 20904
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You shouldn't use suspend() and resume() - the API says why.

Please read this. It has a section called "What should I use instead of Thread.suspend and Thread.resume?".
 
Ernesto Elias-Nieland
Ranch Hand
Posts: 53
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to catch the InterruptedException when doing wait and notify. Wait and notify would be the proper way to pause a thread until a condition becomes true.

You can also call sleep if you just want to stop it for a little while.

Cheers,
Ernie

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!