Open postmodern opened 12 years ago
Add multi-threading to Scanner. This can be done by using the ensure keyword in Scanner#each to stop all scanner threads.
ensure
Scanner#each
class Scanner include Enumerable def each loop do yield rand(256) sleep 1 end ensure puts 'stopping threads' end end scanner = Scanner.new scanner.first(10) # stopping threads # => [30, 165, 245, 11, 43, 159, 13, 113, 128, 197]
Add multi-threading to Scanner. This can be done by using the
ensure
keyword inScanner#each
to stop all scanner threads.Pseudo-code