mercredi 17 juillet 2019

When do we use Synchronised on a java method that handles 'GET'?

Trying to understand Concurrency Concepts. I saw a springboot application with a Controller Class that had 2 methods:

@RequestMapping(value = "/r1", produces = "application/json; charset=utf-8", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<> function1(...){...}

and another one in the same class as:

  @RequestMapping(value = "/r2", produces = "application/json; charset=utf-8", method = RequestMethod.GET)
@ResponseBody
public synchronized ResponseEntity<>(...){....} 

My question is if both methods are in the same class and since a synchronised method locks the whole object of that class, doesn't it lock the non-synchronised method as well?

Aucun commentaire:

Enregistrer un commentaire