stimer.erl

stimer.erl — Erlang source code, 268 bytes

Continguts del fitxer

-module ( stimer1 ).
-export ([ start /1, cancel /1]).

start (Temps ) -> spawn (fun () -> timer (Temps) end ).

cancel (Pid) -> Pid ! cancel.

timer (Tem ) ->
	receive
		cancel -> io:format("S'ha cancelat~n")
		after Tem -> io:format("He acabat~n") 
	end .