I find a problem in "code explorer window".
when I edit java'code,it's display is wrong if the java class has a inner
class.for example:
public abstract class SwingWorker {
private Object value;
private Thread thread;
//next line is a inner class
private static class ThreadVar {
private Thread thread;
ThreadVar(Thread t) { thread = t; }
synchronized Thread get() { return thread; }
synchronized void clear() { thread = null; }
}
//next line context belongs to SwingWorker, not belongs to ThreadVar
private ThreadVar threadVar;
protected synchronized Object getValue() {
return value;
}
private synchronized void setValue(Object x) {
value = x;
}
public abstract Object construct();
public void finished() {}
public void interrupt() {
Thread t = threadVar.get();
if (t != null) {
t.interrupt();
}
threadVar.clear();
}
public Object get() {
while (true) {
Thread t = threadVar.get();
if (t == null) {
return getValue();
}
try {
t.join();
}
catch (InterruptedException e) {
Thread.currentThread().interrupt(); // propagate
return null;
}
}
}
public SwingWorker() {
final Runnable doFinished = new Runnable() {
public void run() { finished(); }
};
Runnable doConstruct = new Runnable() {
public void run() {
try {
setValue(construct());
}
finally {
threadVar.clear();
}
SwingUtilities.invokeLater(doFinished);
}
};
Thread t = new Thread(doConstruct);
threadVar = new ThreadVar(t);
}
public void start() {
Thread t = threadVar.get();
if (t != null) {
t.start();
}
}
}
--
<http://forum.pspad.com/read.php?6,48285,48533>
PSPad freeware editor http://www.pspad.com