from javax.swing.SwingUtilities import invokeLater, invokeAndWait


def invoke(f, wait = False):
    """ Execute function in event thread

    Args:
        f(function reference)
        wait (boolean, optional)
    """
    if is_list(f): [m, a] = f; f = lambda: m(*a)    
    if wait: invokeAndWait(f) 
    else: invokeLater(f)


def x():
    plot([time.time()-start,time.time()-start,time.time()-start,])
#plot([time.time()-start,time.time()-start,time.time()-start,])


start = time.time()
invoke(lambda: plot([time.time()-start,time.time()-start,time.time()-start,]), False)
invoke(x, False)
invoke([plot,[[time.time()-start,time.time()-start,time.time()-start,],]], True)




print time.time() -start


