我正在尝试通过ScannerObject 读取命令.检查我使用的输入语法sc.hasNext()(对于缺少命令的情况).它已经很好地适用于许多情况,但现在我已经在JavaAPI中描述为"可以阻塞并等待输入"的情况.
该hasNext()方法何时阻止,我该如何控制它?有趣的事情是它在块之前的3个案例中完美地工作.此外,JavaAPI描述hasNext()了检查是否存在另一个Input的正确方法,以便Method next()不生成Exception.
这是我到目前为止所做的代码:
if (sc.hasNext() && sc.next().equals("create")) {
if (sc.hasNextInt()) {
width = sc.nextInt();
if (width > 0) {
if (sc.hasNextInt()) {
heigth = sc.nextInt();
if (heigth > 0) {
if (sc.hasNext()) { //At this point the hasNext Statement blocks for //no reason till an Input is made.
charset = sc.next();
Image = new AsciiImage(width, heigth,charset);
} else {
ret = false;
System.out.println("INPUT MISMATCH");
}
} ...//and …Run Code Online (Sandbox Code Playgroud) 我在客户端 - 服务器模型中使用共享内存.当我的服务器被用户使用sigkill而不是sigterm/sigint杀死时,我无法做任何事情(按照预期),但我的共享内存对象和信号量仍然存在于/ dev/shm /中.
下次我启动我的服务器时,我想创建一个名称完全相同的新对象,并且 - 如果有意图 - 这会失败并退出我的程序.
用户需要自己删除对象 - 这当然不是最好的事情.
我怎么处理这个?
我可以在没有O_EXCL标志的情况下调用shm_open(),最终破坏了这个标志的用途.因为可能已经有我的服务器运行的实例并使用此对象.
Pulseaudio似乎使用数字组合来保持它的对象不同,并且不会被-9杀死它,所以似乎有一种方法.
我有一个生成的 lambda,但是当我想观看它时,它就像一个普通的 lambda,它只是不显示任何内容。当我打电话时,expr.Body.ToString()我得到以下信息:
{var compareA; ... }
Run Code Online (Sandbox Code Playgroud)
但是用于表达式的 DebugView 工作正常:
.Lambda #Lambda1<System.Comparison`1[XLinq.Test.Comparers.CustomComparerTest+Test]>(
XLinq.Test.Comparers.CustomComparerTest+Test $x,
XLinq.Test.Comparers.CustomComparerTest+Test $y) {
.Block(System.Int32 $compareA) {
$compareA = .Call ($x.A).CompareTo($y.A);
.If ($compareA != 0) {
.Return #Label1 { $compareA }
} .Else {
.Block(System.Int32 $compareB) {
$compareB = .Call ($x.B).CompareTo($y.B);
.If ($compareB != 0) {
.Return #Label1 { $compareB }
} .Else {
.Block(System.Int32 $compareC) {
$compareC = .Call ($x.C).CompareTo($y.C);
.If ($compareC != 0) {
.Return #Label1 { $compareC }
} .Else {
.Block(System.Int32 …Run Code Online (Sandbox Code Playgroud)