EJB 3.1 container managed concurrency vs. synchronized

前端 未结 2 1535
野趣味
野趣味 2020-12-31 16:07

I\'ve started reading about the singleton session bean and the annotations used to employ container managed concurrency. I don\'t see the benfit of this compared to simply u

2条回答
  •  旧巷少年郎
    2020-12-31 16:26

    Well, as mentioned by Will, with synchronized you can't actually replicate the behavior of javax.ejb.Lock annotations, but you can actually do it by using ReadWriteLock locks, but this is more work in the end.

    As a side note, since singleton instances are not shared across multiple JVMs (meaning they are not distributed objects), there are really no other benefits I can think of that Lock provides aside form ease of use and out of the box support.

    Please also note that "If this annotation is not used, a value of Lock(WRITE) is assumed", so you can't really get rid of it either.

提交回复
热议问题