Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. @RestController
  2. public class DataController {
  3.  
  4. private volatile boolean synchronizing;
  5.  
  6. @GetMapping(value = "api/sync")
  7. public ResponseEntity synchronize() {
  8. if (synchronizing) {
  9. throw new RuntimeException("Already Synchronizing");
  10. }
  11. synchronizing = true;
  12. try {
  13. //Do very long process
  14. } catch (SynchronizationException e) {
  15. throw new RuntimeException(e);
  16. } finally {
  17. synchronizing = false;
  18. }
  19. return ResponseEntity.ok();
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement