update code by referencing http://wiki.processing.org/w/Threading