/** * Called to dispose of resources and shut down the sketch. * Destroys the thread, dispose the renderer,and notify listeners. * <p> * Not to be called or overriden by users. If called multiple times, * will only notify listeners once. Register a dispose listener instead. */ public void dispose() { // moved here from stop() finished = true; // let the sketch know it is shut down time // don't run the disposers twice if (surface.stopThread()) { // shut down renderer if (g != null) { g.dispose(); } // run dispose() methods registered by libraries handleMethods("dispose"); } if (platform == MACOSX) { try { final String td = "processing.core.ThinkDifferent"; final Class<?> thinkDifferent = getClass().getClassLoader().loadClass(td); thinkDifferent.getMethod("cleanup").invoke(null); } catch (Exception e) { e.printStackTrace(); } } }