• Post Reply Bookmark Topic Watch Topic
  • New Topic

On Click of Button i want to start and stop execution of a java class.

 
V Patil
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On Click of Button i want to start and stop execution of a java class.
say on click of start button run below given code.



and on click of stop i want to execute as.stopRequest();.
Please help .
Thanks in advance
 
V Patil
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please helpppppppppppppppppppp.
 
Raffaele Sgarro
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't do it that way... Your thread object "as" must be accessible from the outside world, so you have to make it a class or instance member
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. This is NOT a distributed Java problem
2. You are having a LOT of misconceptions about Java Threads - try to work through some simple examples first.
3. Study the Java Thread API - for example, your code:


does NOT make Thread t sleep. Go read the API carefully.
Bill

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