private AccessibleContext sidePanel;
private HashMap<String,Integer> commodMap;
public PrintStream dtxt = null;
+ private int uploadcounter = 0;
/*
* UTILITY METHODS AND SUBCLASSES
private void debuglog(String s) {
if (dtxt == null) return;
long now = new Date().getTime();
- dtxt.println("progress "+(now - startTime)+"ms "+s);
+ dtxt.println("progress "+(now - startTime)+"ms "
+ +Thread.currentThread().getName()+": "+s);
}
private void debug_write_stringdata(String what, String data)
}
private void progressNote(final String s_in) throws Exception {
- new UIX() { public void body() {
+ new UIA() { public void body() {
String arb = null;
arb = arbitrageResult.getText();
String s = s_in;
if (arb != null && arb.length() != 0)
s = "<html>" + arb + "<br>" + s;
progmon.setNote(s);
- }}.exec("progressNote");
+ }}.exec("progressNote "+s_in);
}
/*
findMarket.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
on_ui_thread();
+ uploadcounter++;
findMarket.setEnabled(false);
resultSummary.setText("");
arbitrageResult.setText("");
- new Thread() {
+ new Thread("MarketUploader-uploader-"+uploadcounter) {
public void run() {
startTime = new Date().getTime();
unknownPCTBcommods = 0;
try {
- runUpload();
+ runUpload(uploadcounter);
} catch(Exception e) {
error(e.toString());
e.printStackTrace();
* error and error_html may be called from any thread
*/
+ private abstract class UIA implements Runnable {
+ private String what;
+ public abstract void body();
+ public void run() {
+ debuglog("UIA 2 "+what+" begin");
+ body();
+ debuglog("UIA 3 "+what+" done");
+ }
+ public void exec(String what_in) {
+ what = what_in;
+ debuglog("UIA 1 "+what+" request");
+ EventQueue.invokeLater(this);
+ }
+ };
private abstract class UIXR<ReturnType> implements Runnable {
public abstract ReturnType bodyr();
public ReturnType return_value;
debuglog("UIX 2 "+what+" begin");
return_value = bodyr();
debuglog("UIX 3 "+what+" done");
- };
+ }
public ReturnType exec(String what_in) throws Exception {
what = what_in;
if (EventQueue.isDispatchThread()) {
debuglog("UIX 4 "+what+" (other thread) exit");
}
return return_value;
- };
+ }
};
private abstract class UIX extends UIXR<Object> implements Runnable {
public abstract void body();
}
private void setProgress(final int nv) throws Exception {
- new UIX() { public void body() {
+ new UIA() { public void body() {
progmon.setProgress(nv);
- }}.exec("setProgress");
+ }}.exec("setProgress "+nv);
}
private boolean isCanceled() throws Exception {
return new UIXR<Boolean>() { public Boolean bodyr() {
* @exception Exception if an error we didn't expect occured
*/
private class YarrgTimestampFetcher extends Thread {
+ public YarrgTimestampFetcher(int counter) {
+ super("MarketUploader-YarrgTimestampFetcher-"+uploadcounter);
+ }
public String ts = null;
public void run() {
try {
}
};
- private void runUpload() throws Exception {
+ private void runUpload(int counter) throws Exception {
on_our_thread();
boolean doneyarrg = false, donepctb = false;
if (uploadToYarrg) {
debuglog("(async) yarrg timestamp...");
- yarrgts_thread = new YarrgTimestampFetcher();
+ yarrgts_thread = new YarrgTimestampFetcher(counter);
yarrgts_thread.start();
}