且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

这段代码中的 StringBuilder 变量线程安全吗?

更新时间:2022-06-01 04:45:50

局部变量是线程安全的,只要没有其他线程以某种方式获得对同一个字符串构建器实例的引用,它就是线程安全的.

Local variables are thread safe, as long as no other thread somehow gets a reference to the same string builder instance, it’s thread safe.