Take the 2-minute tour ×

I have a Java method which runs approximate one or two hours.I made an web ui using jsf and primeface for this.I would like to terminate and restart the method using commandButtons.How do i do that?

I use GlassFish server.


share|improve this question
wow, JSF 3, you're from the future, I suppose ;) –  kostja Aug 5 '12 at 19:17
Sorry I mean Primeface 3.0 :). I fixed it. –  Viplime Aug 5 '12 at 22:18
add comment

2 Answers

up vote 1 down vote accepted
  • Look over the PrimeFaces ShowCase at their command button. Gather ideas.

  • Establish (the use of) an application-level context where a reference to work/thread may be kept. Should this be session based? What's the life-time of a session?

Option: Work - staying on the Java EE path

Option: Thread - texas solution: get er done

share|improve this answer
add comment

In general, if you have a long-running method/job, it's good practice be able to stop (or pause, etc) the job. This is typically done by letting the job run inside its own thread, and to let it frequently check a "stop" flag, which can be set by any other thread. Your command button can set the flag when it is clicked by a user.

This is a common approach to let to threads communicate with each other.

Good luck, Tom

share|improve this answer
Any other suggestion would be helpful :) –  Viplime Aug 6 '12 at 9:27
add comment

Your Answer


