public void removeBot(final Bot bot) { final int idx = bots.indexOf(bot); bot.getScriptHandler().stopAllScripts(); bot.getScriptHandler().removeScriptListener(this); if (idx >= 0) { toolBar.removeTab(idx); } bots.remove(idx); toolBar.setAddTabVisible(bots.size() < MAX_BOTS); new Thread( new Runnable() { public void run() { bot.stop(); System.gc(); } }) .start(); }