This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have a class bo.
and two classes producer (runnable)
and consumer (runnable)
in bo I do producer.start() and consumer.start().
I need executing only once this operation via web.
I mean If the user clic a button then execute the bo and starts the threads.
but If I the user clic again I need to set a String like "running"
You can handle it in the client side itself.
When the user clicks for the first time change the caption to "Running..." and programatically don't make a call to the server side again.
You can easily do it I guess.
Approach suggested by Sujoy Choudhury is best to use for web application.
Here is other way you can restrict thread execution number:
Use a ThreadGroup. Create your thread in a ThreadGroup. You get active thread count from a ThreadGroup, which you can use to check how many threads are present and can prevent creation of new thread.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com