如果我有一个方法Generator.cfc:ColdFusion中的线程安全序列号生成器?
numeric function next()
{
return variables.num++; // Is ++ an atomic operation??
}
和:
application.generator = new generator();
如果每个请求调用application.generator.next(),这将永远发电机产生相同数量的两倍重物?换句话说......这是线程安全的吗?如果不是,锁应该放在哪里?
相关博客文章:的线程安全性在ColdFusion中的整数计数器 - http://blog.bullamakanka.net/2010/01/thread-safety-of-integer-counters-in.html – Henry 2010-01-07 20:20:45