English 中文(简体)
新的洛克比接口在 Java的同步阻挡上有什么好处?
原标题:What is the advantage of new Lock interface over synchronized block in Java?
  • 时间:2011-11-06 08:07:35
  •  标签:
  • java

新的洛克比接口在 Java的同步阻挡上有什么好处? 你们需要执行一个高性能的切身,使多位读者,但只有一位作者能够保持你执行这一成绩的正直性?

问题回答

锁的优点是:

  • it s possible to make them fair
  • it s possible to make a thread responsive to interruption while waiting on a Lock object.
  • it s possible to try to acquire the lock, but return immediately or after a timeout if the lock can t be acquired
  • it s possible to acquire and release locks in different scopes, and in different orders

请注意,这一解释载于rel=“noretinger”>、洛克塔/a>及其子流。

A high performant cache could be implemented using a ConcurrentMap.

锁链接口对同步化的各种优势列于下文。

  1. 协同是导致僵局的唯一主人,不同于没有僵局问题的僵局。

  2. 在同步化过程中,我们不知道,在以前的路面释放了24小时之后,有多少次路面会获得机会。 这可能会导致饥饿问题,而如果出现24小时的情况,我们就会有其执行阶层的宽松的lock,而这种lock子有其建筑之一,让你们把公平财产当作它的论点之一,即让最久的等待read子获得机会。

  3. 在私刑中,如果一对read正在等待另一条read子,那么,等待的read子就没有做任何其它活动,而这种活动不需要锁定,而是用锁定的接口,那么,你可以尝试24小时进入,如果你没有上锁,你可以履行其他替代任务。 这有助于改进申请的执行。

  4. There is no api to check how many threads are waiting for a particular lock whereas this is possible with lock interface implementation class ReentrantLock methods.

  5. 我们可以更好地利用闭锁界面和闭关(Cunt)(未发现同步)方法,更好地控制锁。

多读和并行方案拟订的24个接口的主要优势是,这些接口为阅读和写作提供了两个单独的栏目,使你能够书写像CompHashMap和有条件阻挡等高性能数据结构。

只剩下一只钟。 协同区块不提供任何等待点的机制,在一对read子离开后,任何透镜都能够起锁。 这可能会导致资源在很长一段时间内用于其他一些近似。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签