|  |      1owwlo      2016-10-31 00:37:10 +08:00 #!/usr/bin/ruby require 'rubygems' require 'sinatra/base' require 'thread' class TestSinatra < Sinatra::Base get '/lalala' do "#{settings.store.getCnt}" end end class TempStorage def initialize @cnt = 0 end def tick @cnt += 1 end def getCnt() return @cnt end end def main store = TempStorage.new Thread.new { while true; store.tick(); sleep(0.1); end } TestSinatra::set( :store, store ) TestSinatra::run! end main | 
|      2firefox12 OP 恩 我试试看 |