Skip to content

Instantly share code, notes, and snippets.

@ChunChunMorning
Created December 5, 2016 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChunChunMorning/bc222f20a0b0d0036e7cd14023126c3f to your computer and use it in GitHub Desktop.
Save ChunChunMorning/bc222f20a0b0d0036e7cd14023126c3f to your computer and use it in GitHub Desktop.
# 中略
threads << Thread.new {
loop {
message = parent.gets();
if (message.nil?())
break;
end
puts("parent: #{message}");
args = message.chop().split(",");
if (args[0] == "move")
parent.write("parent," + args[1] + "\n");
child.write("parent," + args[1] + "\n");
elsif (args[0] == "goal")
parent.write("goal\n");
child.write("goal\n");
end
}
}
threads << Thread.new {
loop {
message = child.gets();
if (message.nil?())
break;
end
puts("child: #{message}");
args = message.split(",");
if (args[0] == "move")
parent.write("child," + args[1]);
child.write("child," + args[1]);
end
}
}
# 中略
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment