简体   繁体   中英

Running a Thread What Happens after Page Refresh(Runaway Thread)

So I have a Grails App which uses a java jar. Through the grails app the java program can be run. It can also be stopped and paused. My problem is what happens if the user refreshes the page. The thread become a runaway thread and can be accessed. It will keep going until it finishes. Problem being it writes to a database.

My controller just initializes the java program and controls it, using commands from the gsp.

Is there some way of stopping this or is there a better way of doing it?

Any help is much appreciated,

Use services.

You need to put your database code insite a service and call this service in your controller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM