を失敗した場合、私は本当に、以下のif文が実行されていない理由を知っていない: 文字列の比較と文は
if (s == "/quit")
{
System.out.println("quitted");
}
以下は全体のクラスです。
これはおそらく本当に愚かなロジックの問題ですが、私はここでこれを理解することができずに私の髪を引き出しています。探しているため
感謝:)あなたの例では
class TextParser extends Thread {
public void run() {
while (true) {
for(int i = 0; i < connectionList.size(); i++) {
try {
System.out.println("reading " + i);
Connection c = connectionList.elementAt(i);
Thread.sleep(200);
System.out.println("reading " + i);
String s = "";
if (c.in.ready() == true) {
s = c.in.readLine();
//System.out.println(i + "> "+ s);
if (s == "/quit") {
System.out.println("quitted");
}
if(! s.equals("")) {
for(int j = 0; j < connectionList.size(); j++) {
Connection c2 = connectionList.elementAt(j);
c2.out.println(s);
}
}
}
} catch(Exception e){
System.out.println("reading error");
}
}
}
}
}
私たちは編集に+1を与えることはできません。 –
==手段;これは同じオブジェクトです。同じデータを含むオブジェクトは一致しません。 –
「マルチスレッド」というタグが付いているのはどうですか? – Asaf