首页 \ 问答 \ ReentrantLock公平性参数(ReentrantLock fairness parameter)

ReentrantLock公平性参数(ReentrantLock fairness parameter)

这个问题是完全理论化的,对不起,但这次我无法回避。 我正在学习ReentrantLock阅读

但请注意,锁的公平性并不能保证线程调度的公平性。

这是什么意思? 我怎么能想象这个?

我们假设现在没有人持有锁:

  1. 线程调度程序唤醒t1线程(谁不是最长的等待线程)
  2. t1试图获得锁定
  3. 锁定拒绝t1因为t1不是最长的等待线程
  4. t1进入睡眠状态
  5. 线程调度程序唤醒一个线程

Java是这样工作的吗? 在一个非常不成功的情况下,这将意味着大量的上下文切换(导致吞吐量低,这在文档中写下)。


This question is full theoretical, I'm sorry but I cannot avoid this time. I'm learning about ReentrantLock and read this:

Note however, that fairness of locks does not guarantee fairness of thread scheduling.

What does this mean? How can I imagine this?

Let's suppose that the lock is not held by anyone right now:

  1. thread scheduler wakes up t1 thread (who is not the longest waiting thread)
  2. t1 tries to acquire the lock
  3. lock rejects t1 because t1 is not the longest waiting thread
  4. t1 goes to sleep
  5. thread scheduler wakes up a thread

Does Java work this way? In a very unsuccesful case this would mean lots of context switching (that leads to poor throughput, that is written down in the documentation).


原文:https://stackoverflow.com/questions/47473650
更新时间:2023-08-10 16:08

最满意答案

RedLaser SDK提供MonoTouch 绑定

谷歌代码也提供相同的绑定, 示例和一些说明

但指示(至少)似乎已经过时了。 例如,使用-cxx选项来选择C ++编译器(而不是wiki中提供的符号链接解决方法)。

更新最新的RedLaser绑定(比mono的git存储库更新)绑定可在以下网址获得: https//github.com/chrisbranson/monotouch-bindings示例代码位于: https//github.com/chrisbranson/RedLaserSample


There are MonoTouch bindings available for the RedLaser SDK.

The same bindings, a sample and some instructions are also available on google-code.

But the instructions (at least) seems to be out of date. e.g. use -cxx option to select the C++ compiler (not the symlinks workaround provided in the wiki).

UPDATE Latest RedLaser bindings (newer than mono's git repository) bindings are available at: https://github.com/chrisbranson/monotouch-bindings with sample code available at: https://github.com/chrisbranson/RedLaserSample

相关问答

更多
  • 不要在绑定代码中使用delegate作为参数名称,因为它是C#中的保留字(并且生成器不能与保留字一起使用)。 Try not using delegate as a parameter name in your binding code, since it's a reserved word in C# (and the generator doesn't work properly with reserved words).
  • 微软Rx 我自己创建了一个项目,结合了Rx的codeplex的 Core , Interfaces , Linq和PlatformServices 。 你去那里: https://github.com/stampsy/rx-monotouch 它可以很好地处理引用类型,更不用说值类型(见下文)。 不幸的是,由于bug 8329和9087,它不能编译。 它现在编译得很好。 单反应性 我也使用单反应 ,它对我来说工作得很好。 尽管微软的实施看起来更加简洁和可靠,但单反应更小,更容易在需要时进行修复。 你可以尝试 ...
  • 它们不会出现在IB中,您必须手动输入路径。 在IB中第一次放置图像后,如果重复使用它,它将开始显示。 但即便如此,它只能在同一个XIB文件中执行此操作。 MonoDevelop在一些需要与IB沟通的地方缺乏一点,但它在另一方面做得很好 - 或者对IB的变化作出反应。 They won't show up in IB, you have to type out the path manually. After you put an image in the first time in IB, if you r ...
  • 您可以预先构建数据库, 将其复制到应用程序包中 ,并且(只要它是只读的)您可以随时从应用程序包中直接访问它。 如果需要写访问权限,可以将预先构建的文件复制到其他目录 ,然后从那里进行修改。 You could pre-build your database, copy it into the app bundle, and (as long as it is read-only) you could access it directly from your app's bundle whenever you ...
  • 尝试将-lsqlite3.0添加到LinkerFlags以进行绑定,以指示(本机)链接器加载SQLite库(和符号)。 [assembly: LinkWith ("your_lib.a", LinkTarget.ArmV7, ForceLoad = true, LinkerFlags="-lsqlite3.0")] Try adding -lsqlite3.0 to your LinkerFlags for your binding to instruct the (native) linker to l ...
  • 编辑:下面链接的项目已被删除。 现在,您可以使用视图控制器包含轻松创建自己的嵌套视图控制器。 好吧,我会自己添加另一个答案,虽然我认为Poupos的答案是有效的,但我找到了一个更符合我需求的解决方案:我将MGSplitViewController转换为Monotouch。 :-)它可以在GitHub上的MTSplitViewController上找到https://github.com/Krumelur/MTSplitViewController 我真的希望它能帮助别人。 EDIT: The project ...
  • RedLaser SDK提供MonoTouch 绑定 。 谷歌代码也提供相同的绑定, 示例和一些说明 。 但指示(至少)似乎已经过时了。 例如,使用-cxx选项来选择C ++编译器(而不是wiki中提供的符号链接解决方法)。 更新最新的RedLaser绑定(比mono的git存储库更新)绑定可在以下网址获得: https : //github.com/chrisbranson/monotouch-bindings , 示例代码位于: https : //github.com/chrisbranson/Red ...
  • 代码如: var a = Assembly.Load ("mscorlib.dll"); Assert.NotNull (a); 适用于模拟器和设备。 但是Load的参数是assemblyString ,它不是文件名(即使引发的异常让你认为是这样)。 还存在许多其他重载(对于Load )和其他方法(例如LoadFrom ),但它们可能并非都在MonoTouch内部工作(因为可能缺少一些运行时支持)。 注意 处理mscorlib.dll是特殊的(并且在比其他组件更多的情况下工作,即快捷方式)。 然而,基于反 ...
  • 这是因为产品许可证文件安装在您的用户帐户(工作地点)上,但在您的构建服务器帐户(无法工作)下找不到。 您需要从以下位置复制许可证文件: /Users/***you username**/Library/MonoTouch/License.v2 至: /Users/***your build server account**/Library/MonoTouch/License.v2 请注意,某些版本的Xamarin.iOS(例如Starter和Indie)的许可证不允许您这样做(因此它可能不起作用)。 Tha ...
  • 是的,你需要针对ServiceStack dll的MonoTouch版本编译你的DTO。 原因是因为Xamarin.iOS不支持.NET程序集的完整桌面版本。 相反,它是它们的一部分,就像Silverlight平台一样。 有关更多信息, 请参见此处 注意:Xamarin.iOS与为不同配置文件编译的现有程序集不兼容。 您必须重新编译源代码以生成面向Xamarin.iOS配置文件的程序集(就像您需要重新编译源代码以单独定位Silverlight和.NET 3.5一样)。 虽然Xamarin确实有Visual ...

相关文章

更多

最新问答

更多
  • 获取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的基本操作命令。。。