!752

static JList list;
static int delay = 3000;

p {
  JFrame frame = new JFrame("VMs List");
  frame.setBounds(10, 10, 250, 400);

  list = new JList();
  updateList();
  
  frame.getContentPane().add(new JScrollPane(list));
  frame.setVisible(true);
  
  installTimer(list, runnable {
    updateList();
  }, delay);
}

static new MonoThread update;

!include #1001434 // MonoThread

static void updateList() {
  update.run(runnable {
    new L<S> vms;
    for (DialogIO vm : talkToAllVMs()) {
      S pid = vm.ask("what is your process id");
      S progs = vm.ask("which programs are you running (ids only)?");
      new Matches m;
      if (match3("these: *", progs, m))
        progs = unquote(m.m[0]);
      vms.add(pid + ": " + progs);
    }
    fillListWithStrings(list, vms);
  });
}