首页 \ 问答 \ IBM JVM版本7中未知锁的所有者(Owner of lock unknown in IBM JVM version 7)

IBM JVM版本7中未知锁的所有者(Owner of lock unknown in IBM JVM version 7)

我有一种情况,在一些ReentrantReadWriteLock上阻塞了很多线程,但由于某种原因,所有者不知道。

3XMTHREADBLOCK     Parked on:
java/util/concurrent/locks/ReentrantReadWriteLock$NonfairSync@0xC3C0E5E8 Owned by: <unknown>

这是因为所有者线程存在吗?
为什么JVM不释放锁?
还有其他原因吗?


I have a situation where lots of threads are blocked on some ReentrantReadWriteLock but for some reason the owner is not known.

3XMTHREADBLOCK     Parked on:
java/util/concurrent/locks/ReentrantReadWriteLock$NonfairSync@0xC3C0E5E8 Owned by: <unknown>

Is this because the owner thread has existed?
Why doesn't the JVM release the lock?
Can there be other reasons?


原文:https://stackoverflow.com/questions/27456187
更新时间:2024-03-06 13:03

最满意答案

我认为你应该用这个循环替换你建议的(但不正确的)代码行:

    if (i != numberOfGuesses) {
      System.out.println("You did not use these guesses: ");
      for (int j = i + 1; j <= numberOfGuesses; j++) {
        System.out.println(j);
      }
    }

此外,您还有一个错误:如果您在开始时回答“是”,则一切正常,您可以玩游戏。 但是,如果您回答是(如问题中提出的)或任何其他文本,它会等待另一个输入,并且当您输入内容并按下回车键时,它会继续游戏。 所以,如果输入“否”,按回车,输入1,按回车键仍然会播放。


I think that you should replace your proposed (but incorrect) line of code with this loop:

    if (i != numberOfGuesses) {
      System.out.println("You did not use these guesses: ");
      for (int j = i + 1; j <= numberOfGuesses; j++) {
        System.out.println(j);
      }
    }

Also, you have a bug: if you answer yes in the beginning, everything's fine and you play the game. But if you answer Yes (as proposed in the question) or any other text, it waits for another input and when you do input something and press enter, it continues to the game. So, if you enter "No", press enter, enter 1, press enter it will still play.

相关问答

更多
  • 首先欢迎来到StackOverflow。 很高兴看到你找到并使用了家庭作业标签。 请记住,对于能够帮助您的人,您需要提供更多信息。 你是什么意思错误,运行代码时会发生什么等 关于你得到的错误,看起来你没有真正定义类Card和Player ,你的代码中有你在GuessingGame类中的两种方法GuessingGame.Card()和GuessingGame.Player() 。 将它们更改为内部(或外部)类,它应该没问题;) First of all welcome to StackOverflow. It ...
  • 你可以这样做: if(a.length>0) { int i=0,j=0; do{ j=i+1; while(j
  • 简单的回答。 在玩家成功完成第一轮之后,在开始第二轮之前,您没有初始化“keepPlaying”循环中的所有必要值。 请参阅下面的代码注释: import java.util.Random; import java.util.Scanner; public class GuessingGame { public static void main(String[] args) { Random rand = new Random(); int TAL = r ...
  • 您的generateWinningNumber()方法返回一个double,它实际上不会更改任何值本身。 另外,因为WINNING_NUMBER是一个常量,即使你确实想要改变它,你也无法做到。 你绝对不应该使WINNING_NUMBER最终,并修改generateWinningNumber()以便它自己修改你的全局变量,或者保持原样,并使用它的返回值分配给你的非常量winningNumber全局。 Your generateWinningNumber() method returns a double, i ...
  • 我认为你应该用这个循环替换你建议的(但不正确的)代码行: if (i != numberOfGuesses) { System.out.println("You did not use these guesses: "); for (int j = i + 1; j <= numberOfGuesses; j++) { System.out.println(j); } } 此外,您还有一个错误:如果您在开始时回答“是”,则一切正常,您可以 ...
  • 编辑答案,因为我先读错了这个问题,道歉! 好的,我们打破这个。 首先,我们如何检查两个数字是否连续? 如果他们相互追赶。 这是正确的,但我们如何通过编程表达这一点? 它实际上非常简单,如果它们之间的差值等于1,则两个数字是连续的。因此,检查两个数字是否是连续的,只需减去它们并查看结果是否为1(或-1,具体取决于顺序)。 现在,这个问题的完整解决方案有点复杂。 我们需要找到生成的乐透号码中连续的所有数字。 因此,为了更好地解决这个问题,我建议将此部分放入一个单独的方法中,称为getConsecutiveNum ...
  • 问题 下面这段代码似乎试图显示一个单词中可以找到正确选择的字母的位置 if (SecretWord.indexOf(guess) >= 0) { UpWord = dash.substring(0, SecretWord.indexOf(guess)); UpWord += guess; UpWord += dash.substring(SecretWord.indexOf(guess) + 1, dash.length()); Sys ...
  • 如果你在循环中包含零,那么A - B mod R或B - A mod R中的问题会变小 R = 9 8 - 3 mod 9 = 5 3 - 8 mod 9 = 4 min(5 3) = 3 你可以通过递减你读取的数字来减少猜测零点的效果,并且如果你允许他们猜测数字零,你可以在数学上更容易地计算你打印的数字。 (defn mod- [x y r] (let [res (rem (- x y) r)] (if (neg? res) (+ res r) res))) (min (mo ...
  • 在您的elif中添加if条件,以便: 如果number_guessed在computer_guesses_list中:再次生成一个随机数 Add an if condition in your elif such that : if number_guessed is in computer_guesses_list: generate a random number again

相关文章

更多

最新问答

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