def METHOD_NAME(time):
    try:
        SIGALRM
    except NameError:
        raise NotImplementedError("alarm not implemented on this platform")
    def raise_alarm():
        sun.misc.Signal.raise(_signals[SIGALRM])
    if time > 0:
        new_alarm_timer = _Alarm(time, raise_alarm)
    else:
        new_alarm_timer = None
    old_alarm_timer = _alarm_timer_holder.getAndSet(new_alarm_timer)
    if old_alarm_timer:
        scheduled = int(old_alarm_timer.cancel())
    else:
        scheduled = 0
    if new_alarm_timer:
        new_alarm_timer.start()
    return scheduled