ReentrantLock公平性参数(ReentrantLock fairness parameter)
这个问题是完全理论化的,对不起,但这次我无法回避。 我正在学习
ReentrantLock
并阅读 :但请注意,锁的公平性并不能保证线程调度的公平性。
这是什么意思? 我怎么能想象这个?
我们假设现在没有人持有锁:
- 线程调度程序唤醒
t1
线程(谁不是最长的等待线程)t1
试图获得锁定- 锁定拒绝
t1
因为t1
不是最长的等待线程t1
进入睡眠状态- 线程调度程序唤醒一个线程
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:
- thread scheduler wakes up
t1
thread (who is not the longest waiting thread)t1
tries to acquire the lock- lock rejects
t1
becauset1
is not the longest waiting threadt1
goes to sleep- 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
最满意答案
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).
-
我可以在MonoTouch项目中使用Reactive Extensions吗?(Can I use Reactive Extensions in a MonoTouch project?)[2023-06-05]
微软Rx 我自己创建了一个项目,结合了Rx的codeplex的 Core , Interfaces , Linq和PlatformServices 。 你去那里: https://github.com/stampsy/rx-monotouch 它可以很好地处理引用类型,更不用说值类型(见下文)。 不幸的是,由于bug 8329和9087,它不能编译。 它现在编译得很好。 单反应性 我也使用单反应 ,它对我来说工作得很好。 尽管微软的实施看起来更加简洁和可靠,但单反应更小,更容易在需要时进行修复。 你可以尝试 ... -
MonoTouch资源(MonoTouch Resources)[2021-07-19]
它们不会出现在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 ...
-
如何在MonoTouch绑定项目中添加libsqlite3.0.dylib?(How to add the libsqlite3.0.dylib in MonoTouch Binding Project?)[2021-10-15]
尝试将-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 ... -
如何在Monotouch中使用MGSplitViewController?(How to get MGSplitViewController working in Monotouch?)[2022-10-25]
编辑:下面链接的项目已被删除。 现在,您可以使用视图控制器包含轻松创建自己的嵌套视图控制器。 好吧,我会自己添加另一个答案,虽然我认为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 ...