This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Semaphore | |
| @resource=1 | |
| def GetResource | |
| while true do | |
| unless @resource==0 | |
| @resource-=1 | |
| break | |
| end | |
| sleep 1 | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Prime | |
| include Enumerable | |
| def initialize(num = 100) | |
| ary = (3..num).to_a | |
| @prime = [2] | |
| ary.each do |item| | |
| tmp = 0 | |
| flag = true | |
| @prime.each do |pr| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### Keybase proof | |
| I hereby claim: | |
| * I am toushimi on github. | |
| * I am toushimi (https://keybase.io/toushimi) on keybase. | |
| * I have a public key ASCKEJ3RIO1imVxhqKmvHOl3CrYHOlHYe5juqm3FRrgNygo | |
| To claim this, I am signing this object: |