Created
August 29, 2019 13:10
-
-
Save liprais/4d3edfb5931076a5a9ec8b3c95d34273 to your computer and use it in GitHub Desktop.
58 my ass
This file contains 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
require 'mysql2' | |
client = Mysql2::Client.new(:host => "localhost", :username => "root",:database => "test") | |
100.times do |i| | |
str = "insert into money_test ( money) values (#{rand(100)})" | |
p str | |
client.query(str) | |
end | |
def exec() | |
money = -1 | |
client = Mysql2::Client.new(:host => "localhost", :username => "root",:database => "test") | |
client.query("select id,money from money_test where id = 89").each do |row| | |
p money = row['money'] | |
end | |
update_string = "update money_test set money = #{money} + 1 where id = 89 and money = #{money}" | |
client.query(update_string) | |
end | |
a = [] | |
5.times { a << Thread.new { exec } } | |
a.map { |i| i.join } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment