123456789101112131415161718192021 |
- package J20250730.demo12_synchronizedCollection;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.List;
- /**
- * @author WanJl
- * @version 1.0
- * @title Demo01
- * @description
- * @create 2025/7/30
- */
- public class Demo01 {
- public static void main(String[] args) {
- ArrayList<String> l=new ArrayList<>();
- //这就是把线程不安全的集合,封装为线程安全的集合
- List<String> list = Collections.synchronizedList(l);
- }
- }
|