📄 lookupthread.java
字号:
//LookupThread.java
import java.net.*;
import java.io.*;
import java.util.*;
public class LookupThread extends Thread {
private List entries;
PooledWeblog log; //在回调的时候使用
public LookupThread(List entries, PooledWeblog log) {
this.entries = entries;
this.log = log;
}
public void run( ) {
String entry;
while (true) {
synchronized (entries) {
while (entries.size( ) == 0) {
if (log.isFinished( )) return;
try {
entries.wait( );
}
catch (InterruptedException e) {
}
}
entry = (String) entries.remove(entries.size( )-1);
}
int index = entry.indexOf(' ', 0);
//获得远程主机地址
String remoteHost = entry.substring(0, index);
String theRest = entry.substring(index, entry.length( ));
try {
remoteHost =
InetAddress.getByName(remoteHost).getHostName( );
}
catch (Exception e) {
}
try {
log.log(remoteHost + theRest);
}
catch (IOException e) {
}
this.yield( );
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -