@XmlRootElement(name = "super-xml")
@XmlSeeAlso(OtherSuperXml.class)
public class MySuperXml {
@XmlElement(name = "number")
private List<Long> numbers;
}
@XmlRootElement(name = "other-super-xml")
public class OtherSuperXml extends MySuperXml {
@XmlElement(name = "name")
private List<String> names;
}
public class Worker {
private boolean destroy;
private boolean destroyed;
private counter;
public void destroy() {
synchronized (this) {
if (this.destroyed) {
return;
}
this.destroy = true;
if (this.counter != 0) {
return;
}
this.destroyed = true;
}
destroyImpl();
}
public void service(String arg) {
synchronized (this) {
if (this.destroy) {
return;
}
++this.counter;
}
serviceImpl(arg);
synchronized (this) {
if (--this.counter != 0) {
return;
}
if (!this.destroy) {
return;
}
this.destroyed = true;
}
destroyImpl()
}
}
Process.waitFor()
? Потому что иначе вызывающая программа не ожидает завершения вызванной. Вот код для примера:import java.io.IOException;
public class Run {
public static void main(String[] args) {
try {
new ProcessBuilder("/usr/bin/kwrite").start();
} catch (IOException e) {
e.printStackTrace();
}
}
}