This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes On Click of Button i want to start and stop execution of a java class. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "On Click of Button i want to start and stop execution of a java class." Watch "On Click of Button i want to start and stop execution of a java class." New topic
Author

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

V Patil
Ranch Hand

Joined: Oct 04, 2008
Posts: 36
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

Joined: Oct 04, 2008
Posts: 36
Please helpppppppppppppppppppp.
Raffaele Sgarro
Greenhorn

Joined: Nov 05, 2009
Posts: 5
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

Joined: Mar 22, 2000
Posts: 12269
    
    1
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


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: On Click of Button i want to start and stop execution of a java class.
 
Similar Threads
Question about ActionListener
polymorphism by using interface and inheritance
This code tells me i don't have a main()
Close Browser window stop thread
Stoping multiple threads