解决方法
我不会指望
2008年matz wrote:@H_403_3@
For MRI (1.8.x) and YARV (1.9.x),every C implemented methods are
protected by GIL (Global Interpreter Lock),so that you don’t have to
worry about. But it might depend on each implementation.@H_403_3@
Net :: HTTP在stdlib中,这意味着它没有在C中实现(或者至少没有在C中完全实现).我假设matz在GIL上的说明今天仍然是正确的,这意味着GIL不会放在Net :: HTTP上.因此,我怀疑这将是线程安全的.@H_403_3@
我不幸的是没有在当前版本的Ruby的文档中找到明确的证据,虽然我觉得这也值得一提,从Concurrency in jruby:@H_403_3@
At least these classes [core classes and classes in the stdlib] are
not considered thread-safe,and if you intend to mutate them
concurrently with other operations you will want to introduce locking
(e.g. with Mutex): String,Array,Hash,and any data structures
derived from them.@H_403_3@