jGrasp Java Break Ctrl-C 在運行期間 (jGrasp Java Break Ctrl-C during Run)


問題描述

jGrasp Java Break Ctrl-C 在運行期間 (jGrasp Java Break Ctrl-C during Run)

I have a while(true) loop running for a Java server (to listen) that I am trying to learn.  I utilize jGrasp for compiling and running.  

After a connection is made and disconnected the server is of course still "listening"

What I would like to know is how to manualy send a break (like a ctrl-c) in jGrasp ?  

I noticed that simply hitting END will stop the program but of course it will never reach the socket.close() method and this of course causes other issues.


參考解法

方法 1:

One way of doing this would be to create a variable and set it to true and have your loop be while(variable)... Then using the debugger (not sure if you can do this in jGrasp) you can change the value of the variable (to false) mid execution if you setup a breakpoint inside the loop. After changing it on the next loop evaluation that variable will be false and it will exit the loop.

(by KairanSlava Markeyev)

參考文件

  1. jGrasp Java Break Ctrl-C during Run (CC BY-SA 3.0/4.0)

#java #jgrasp






相關問題

電子郵件地址中帶有 + 字符的 Java 郵件 (Java mail with + character in email address)

如何快速原型化 Java 代碼? (How to quickly prototype Java code?)

如何使用 Maven 在目標(SVN-)服務器上創建 Javadoc? (How to create Javadoc on the target (SVN-) server using Maven?)

為什麼檢查二叉樹有效性的解決方案不起作用? (Why the solution for checking the validity of binary tree is not working?)

Selenium webdriver通過第一個數字找到texy (Selenium webdriver find texy by first digits)

setOnClickListener 沒有在圖像視圖上被調用 (setOnClickListener is not getting called on image view)

繪製多邊形:找不到錯誤 (Drawing Polygon : unable to find error)

半透明 JButton:對像出現在背景中 (Semi-Transparent JButton: Objects appear in Background)

比較同一數組的元素 (Compare elements of the same array)

Java 屏幕截圖小程序 (Java screen capture applet)

Minecraft 1.8.9 Forge Modding 的Java 開發工具包,需要什麼JDK/JRE,代碼是否正確? (Java Development Kit with Minecraft 1.8.9 Forge Modding, What JDK/JRE Is Needed, Is Code Correct?)

java while (resultset.next()) 不返回同一列中的所有數據 (java while (resultset.next()) does not return all data in the same column)







留言討論