Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个示例,它演示了轻量级设计模式,游戏中有士兵。这个士兵实例必须同时被多个客户端使用。这个链接说如果它在地图(或缓存)中可用,则返回相同的对象。并发使用同一个对象不是不安全的,因为线程可能会改变它的属性。
是的。享元模式只能用于不可变对象,无论是在单线程还是多线程环境中使用。