当前线程不是所有者例外

编程入门 行业动态 更新时间:2024-10-19 17:18:14
本文介绍了当前线程不是所有者例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的应用程序中我正在使用运行批处理文件的代码,在执行它时我得到一个例外,即当前线程不是所有者。 这里我想提一下我的应用程序是基于eclipse插件开发的。 以下是我的代码,请看一下,看看有什么问题可以帮助我..

in my application i am using a code that run a batch file, on executing it i am getting a exception i.e. current thread is not owner. Here i want to mention that my application is based on eclipse plugin development. Following is my code, please have a look and find out what is the problem to help me..

/*.......any code.........*/ try { Runtime runtime = Runtime.getRuntime(); String cmd = new String(C:\\abc.bat); process = runtime.exec("\"" + cmd + "\""); process.wait(); } catch (Exception e) { e.printStackTrace(); } /***********any code**************/

推荐答案

等待是Object拥有的方法,要使用该方法,必须获取锁定对象,将代码更改为,

The wait is the method owned by Object, to use the method, you must get the lock of the object, change your code to,

try { Runtime runtime = Runtime.getRuntime(); String cmd = new String(C:\\abc.bat); process = runtime.exec("\"" + cmd + "\""); synchronized (process){ try{ process.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); }

更多推荐

当前线程不是所有者例外

本文发布于:2023-11-09 20:48:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573398.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:所有者   线程

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!