67,513
社区成员
发帖
与我相关
我的任务
分享
SSLSocket s = (SSLSocket) serverSocket.accept();
Thread_01 t1 = new Thread_01();
//Thread_01是在Socket监听到连接后建立的Thread
class Thread_01 extends Thread{
InputStread bis = socket.getInputStream();
private String Function_002(){
Strign tmp = Function_001();
if(tmp.equals("abc")){
//Function001里新建了一个Thread_02,并且在synchronized里start了
//那是不是应该不等这个子Thread_02执行完,就执行if(tmp.equals("abc"))呢?
}
}
private String Function_001(){
String result;
Thread Thread_02 = new Thread() {
@Override
public void run() {
try {
while (result=bis.readLine()==null);
//这是从Thread_01里已经建立的Socket里读值,读到值后才推出while循环。
}catch (IOException e) {
e.printStackTrace();
}
synchronized (lock) {
lock.notifyAll();
}
}
}
try {
synchronized (lock) {
thread_02.start();
lock.wait(1000);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
return result;
}
}
private String Function_001(){
final Object lock = new Object();
String result;
Thread Thread_02 = new Thread() {
@Override
public void run() {
try {
while (result=bis.readLine()==null);
//这是从Thread_01里已经建立的Socket里读值,读到值后才推出while循环。
}catch (IOException e) {
e.printStackTrace();
}
synchronized (lock) {
lock.notifyAll();
}
}
}
try {
synchronized (lock) {
thread_02.start();
lock.wait(1000);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
return result;
}