English 中文(简体)
等待(长时间停业)与加入(长米)之间的差异?
原标题:Difference between wait(long timeout) and join(long millis)?

两套等待()和“()”方法,如果一对二读,则一对二读,要么在一段时间内,要么在接近二读完成。

如果我们使用这些方法的超负荷版本,即等待(长时间停用)和加入(长米),那么

  1. In case of wait(long timeout), thread-1 will become runnable either by notify (or notifyall) or even timeout occurs (whichever is first).

  2. 在加入(长米)的情况下,在二读完成或时间(以先为准)时,二读即行即行。

因此,这两种执行之间的区别是什么?

有些人认为是:

  1. For wait(), we need to have the lock on the object we are waiting on. For join() these are not necessary.
  2. After executing wait(), the thread removes lock it obtained and re-gains the lock once it becomes running again. But what about join? Does a thread removes a lock after executing join if this was executed from a synchronized block (or method)?
最佳回答

如你所说,“释放”程序差别很大,在一种情况下(wait)是以<条码>说明(<>/条码”为依据的,另一种(加入)程序则以读写为基础。 他们重复了完全不同的目的。

事实上,有以下明确警告:wait(>>>> on Thread/code> 监测(尽管我可以立即找到这些警告),因为内部 Java代码为它们购买了锁(并使用wait/>>>>>>>> 说明本身)。

但没有,请在<条码>上打<>条码>。 如果目前的执行者拥有监测权,则释放监测员。

从根本上说,你根本不认为它们是类似的——一个是等待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 ...

热门标签