对于ReentrantLock,实际使用lockInterruptibly [英] Actual use of lockInterruptibly for a ReentrantLock

查看:345
本文介绍了对于ReentrantLock,实际使用lockInterruptibly的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您实际使用此方法 lockInterruptibly ?我已阅读 API 但是对我来说不是很清楚。换句话说,有人可以表达吗?

What do you actually use for this method lockInterruptibly? I have read the API however it's not very clear to me. Could anybody express it in other words?

推荐答案

逻辑与所有可中断的阻塞方法相同:它允许线程到立即对从另一个线程发送给它的中断信号做出反应。

The logic is the same as for all interruptible blocking methods: it allows the thread to immediately react to the interrupt signal sent to it from another thread.

如何使用此特定功能取决于应用程序设计。例如,它可以用来杀死池中的一些线程,这些线程都在等待获取锁定。

How this particular feature is used is up to the application design. For example, it can be used to kill a contingent of threads in a pool which are all waiting to aquire a lock.

这篇关于对于ReentrantLock,实际使用lockInterruptibly的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆