<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def validator(ch):
 """ Update screen if necessary and release the lock so receiveThread can run """

    global screen_needs_update
    try:
        if screen_needs_update:
            curses.doupdate()
            screen_needs_update = False
        return ch
    finally:
        winlock.release()
        sleep(0.01) # let receiveThread in if necessary
        winlock.acquire()