lisai17@sina.com 2020-10-18 22:49:28 +08:00
parent a54d1ad330
commit af6ccba925
1 changed files with 3 additions and 2 deletions

View File

@ -52,6 +52,7 @@ public class LEDThread extends Device implements Runnable {
}; };
private ReentrantLock lock = new ReentrantLock(); private ReentrantLock lock = new ReentrantLock();
private ReentrantLock connlock = new ReentrantLock();
protected Socket socket; protected Socket socket;
public LEDThread(String id, String ip) { public LEDThread(String id, String ip) {
@ -245,7 +246,7 @@ public class LEDThread extends Device implements Runnable {
@Override @Override
public boolean connect() throws IOException { public boolean connect() throws IOException {
lock.lock(); connlock.lock();
try { try {
socket = new Socket(); socket = new Socket();
socket.setSoTimeout(1000); socket.setSoTimeout(1000);
@ -259,7 +260,7 @@ public class LEDThread extends Device implements Runnable {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
} finally { } finally {
lock.unlock(); connlock.unlock();
} }
return isConnected(); return isConnected();