Threads
Ruby
code posted
created at 28 Mar 21:55
Edit
|
Back
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
threads = [] mutex = Mutex.new quit = false threads << Thread.new do while !mutex.synchronize{quit} # Uhrzeit abrufen # Ausgabe an Statuszeile end end threads << Thread.new do while !mutex.synchronize{quit} # Mails abrufen # Ausgabe an Statuszeile sleep 300 # Oder wie du willst end end trap(:SIGTERM) do mutex.synchronize{quit = true} end sleep 5 while !mutex.synchronize{quit} threads.each(&:join) |
459 Bytes in 2 ms with coderay