首页 \ 问答 \ 在调用wait()之前调用锁对象的notify()是否可以?(Is it okay to call notify() on a lock object before calling wait() on it?)

在调用wait()之前调用锁对象的notify()是否可以?(Is it okay to call notify() on a lock object before calling wait() on it?)

我在我的代码中使用wait()和notify(),并且有一种情况,在另一个线程的锁对象上实际调用等待之前,执行可以先到达notify()。 我在锁对象中创建了一个“isWaitCalled”标志,并且如果wait()没有被调用,就使用它跳过notify()调用。 这个标志“isWaitCalled”是多余的吗? 在等待其中一个场景之前调用notify()是否可以? 主题A:

synchronized (syncObject) {
          try {
                if (!syncObject.isLoadComplete) {
                    syncObject.isWaitCalled = true;
                    syncObject.wait();
                }
          } catch (Exception ex) {
          }                                              
    }

ThreadB:

synchronized (syncObject) {
          try {
                if (!syncObject.isLoadComplete) {
                  syncObject.isLoadComplete =true;
                   if (syncObject.isWaitCalled) {
                       syncObject.notify();         
                   }                  
               }
          } catch (Exception ex) {
          }                                              
    }

I am using wait() and notify() in my code and there is a scenario where the execution can reach notify() first before a wait is actually called on the lock object on another thread. I created a flag "isWaitCalled" in the lock object and using it to skip notify() call if wait() is not called already. Is this flag "isWaitCalled" redundant? Is it okay if notify() is called before wait in one of the scenarios? Thread A:

synchronized (syncObject) {
          try {
                if (!syncObject.isLoadComplete) {
                    syncObject.isWaitCalled = true;
                    syncObject.wait();
                }
          } catch (Exception ex) {
          }                                              
    }

ThreadB:

synchronized (syncObject) {
          try {
                if (!syncObject.isLoadComplete) {
                  syncObject.isLoadComplete =true;
                   if (syncObject.isWaitCalled) {
                       syncObject.notify();         
                   }                  
               }
          } catch (Exception ex) {
          }                                              
    }

原文:https://stackoverflow.com/questions/40432886
更新时间:2023-10-01 11:10

最满意答案

激活图像版本控制的第一件事是:

1)转到站点设置2)单击类型3)从下拉列表中选择图像4)选择自动版本控制

即便如此,我认为不会自动为ImageEditor更改执行版本控制。 ImageEditor只是设置图像的字段值,并且不会发出任何对象修改的事件,我认为这是plone版本控制所需要的。

FWIW,我是Products.ImageEditor的作者。 如果您愿意,可以提交问题的故障单: https//github.com/collective/Products.ImageEditor/issues


First thing to activate version control for images is to:

1) go to site setup 2) click Types 3) Select Image from the drop down 4) select Automatic versioning

Even with that, I don't think versioning will not automatically be performed for ImageEditor changes. ImageEditor just sets the field value for the image and does not emit any object modified events which I assume is required for plone's versioning to kick in.

FWIW, I'm the author of Products.ImageEditor. You can submit a ticket for the issue if you'd like: https://github.com/collective/Products.ImageEditor/issues

相关问答

更多
  • Plone 4.1应该很快就会看到一个候选版本(这将成为最终版本)。 没有已知的阻挡者了。 如果你开始在新网站上工作,一定要去做。 对于现有站点的升级,我会等待一段时间,直到最终版本发布。 Plone 4.1 should see a release candidate very soon (which will then become the final release). There's no known blockers left anymore. If you start working on a ...
  • 你可以禁用它们。 您将失去一些渐进式增强功能(例如拖动文件以在内容选项卡上重新排序),但该网站仍应可用。 或者你可以升级到Plone 4.3,它不再使用KSS。 You can disable them. You'll lose some progressive enhancement features (ability to drag files to reorder on the Contents tab, for example), but the site should still be usabl ...
  • 要创建更多plone网站,请转到: http://:/manage 例如: http://localhost:8080/manage 您会在右上角的“添加Plone站点”中找到一个按钮。 To create more plone sites just go to: http://:/manage for example: http://localhost:8080/manage There you'll find a button in ...
  • 激活图像版本控制的第一件事是: 1)转到站点设置2)单击类型3)从下拉列表中选择图像4)选择自动版本控制 即便如此,我认为不会自动为ImageEditor更改执行版本控制。 ImageEditor只是设置图像的字段值,并且不会发出任何对象修改的事件,我认为这是plone版本控制所需要的。 FWIW,我是Products.ImageEditor的作者。 如果您愿意,可以提交问题的故障单: https : //github.com/collective/Products.ImageEditor/issues F ...
  • 来自加利福尼亚酒店的提示:“你可以随时查看,但你永远不能离开。” 你真的不想禁用所有下载,我相信你真的只想禁用所有用户的下载,但所有者。 没有实际用途可以将文件放入没有车辆的东西中,以便让它们退回... ...所以你需要用工作流来解决这个问题: 使用具有此行为状态的自定义工作流定义(“机密”)。 确保未在此状态的权限中从上面的文件夹继承“查看”权限,并选中“所有者”(如果您认为合适,可能还有“管理员”)具有“查看”权限。 将机密状态设置为文件的默认状态。 如果您不希望在站点范围内执行此操作,则可以使用站点部 ...
  • 按照https://github.com/vincent-psarga/collective.sendaspdf上的说明为我工作。 编辑 :啊,既然你已经发布了你的整个buildout.cfg我可以看到问题。 parts = section必须是[buildout]节的一部分。 它目前在[wkhtmltopdf_executable] 。 设置初始用户也是如此。 请注意,您已经包含了管理员密码,所以如果真的是密码,我现在就改变它! Following the instructions at https:// ...
  • 这似乎是由于Zope 2.13.8和ZTK 1.0.3条目被错误输入good-py。 它现在应该修复。 This appears to be due to the Zope 2.13.8 and ZTK 1.0.3 entries being incorrectly entered into good-py. It should be fixed now.
  • 创建(或编辑)集合时,可以添加“位置”条件,并指定文件夹的路径。 保存后,该集合将仅显示该文件夹内的内容(并且除此标准外,还添加了作为该集合的过滤器添加的所有其他条件)。 When you create (or edit) the collection, you can add a Location criterion, and specify the path to the folder. After you save, the collection will only show content from ...
  • 内容对象由多个持久性记录组成。 对于包含文件系统上的二进制blob文件的图像和文件。 更改内容对象时, 只有受更改影响的持久性记录才会写入事务的一部分。 那时候没有清除旧记录,所以你确实得到了多份副本,是的。 因此,每次更改文件或图像的二进制内容时,都会使用该新数据创建新副本,并保留旧版本。 但是,如果您只更改标题或发布日期,则blob文件不会受到影响,您将不会得到其他未更改数据的额外副本。 您使用ZODB打包来删除旧的交易数据。 请注意,通过打包,您还可以删除撤消包已删除旧状态的更改的功能。 Conten ...
  • 您还可以通过http://docs.diazo.org/en/latest/deployment.html中列出的任何非Plone部署方法运行Diazo。 你将失去所有Plone TTW集成,但如果你可以手动构建和编译你的主题,那么你就完全没有了。 You can also run Diazo via any of the non-Plone deployment methods listed at http://docs.diazo.org/en/latest/deployment.html. You'l ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。