JUC高并发编程4:集合的线程安全

news2024/9/29 23:49:06

1 内容概要

在这里插入图片描述

2 ArrayList集合线程不安全

2.1 ArrayList集合操作Demo

  • 代码演示
/**
 * list集合线程不安全
 */
public class ThreadDemo4 {
    public static void main(String[] args) {
        // 创建ArrayList集合
        List<String> list = new ArrayList<>();
        
        for (int i = 0; i < 30; i++) {
            new Thread(()->{
                // 向集合中添加内容
                list.add(UUID.randomUUID().toString().substring(0,8));
                // 从集合中获取内容
                System.out.println(list);
            },String.valueOf(i)).start();
        }
    }
}
  • 运行结果
    在这里插入图片描述

  • 异常内容
    java.util.ConcurrentModificationException

  • 问题:为什么会出现并发修改异常
    查看ArrayList的add方法源码:

/**
* Appends the specified element to the end of this list.
*
* @param e element to be appended to this list
* @return <tt>true</tt> (as specified by {@link Collection#add})
*/
public boolean add(E e) {
   ensureCapacityInternal(size + 1);  // Increments modCount!!
   elementData[size++] = e;
   return true;
}

那么我们如何去解决 List 类型的线程安全问题?

2.2 解决方案:Vector

Vector 是矢量队列,它是 JDK1.0 版本添加的类。继承于 AbstractList,实现了 List, RandomAccess, Cloneable 这些接口。 Vector 继承了 AbstractList,实现了 List;所以,它是一个队列,支持相关的添加、删除、修改、遍历等功能。 Vector 实现了 RandmoAccess 接口,即提供了随机访问功能
RandmoAccess 是 java 中用来被 List 实现,为 List 提供快速访问功能的。在Vector 中,我们即可以通过元素的序号快速获取元素对象;这就是快速随机访问。 Vector 实现了 Cloneable 接口,即实现 clone()函数。它能被克隆。
和 ArrayList 不同,Vector 中的操作是线程安全的。

  • 代码修改1:Vector实现
/**
 * Vector实现:list集合线程安全
 */
public class ThreadDemo4 {
    public static void main(String[] args) {
        // 创建ArrayList集合
        List<String> list = new Vector<>();
        
        for (int i = 0; i < 30; i++) {
            new Thread(()->{
                // 向集合中添加内容
                list.add(UUID.randomUUID().toString().substring(0,8));
                // 从集合中获取内容
                System.out.println(list);
            },String.valueOf(i)).start();
        }
    }
}
  • 现在没有运行出现并发异常,为什么?
    查看 Vector 的 add 方法
/**
 * Appends the specified element to the end of this Vector.
 *
 * @param e element to be appended to this Vector
 * @return {@code true} (as specified by {@link Collection#add})
 * @since 1.2
 */
public synchronized boolean add(E e) {
    modCount++;
    ensureCapacityHelper(elementCount + 1);
    elementData[elementCount++] = e;
    return true;
}

add 方法被 synchronized 同步修辞,线程安全!因此没有并发异常

2.3 解决方案:Collections

Collections 提供了方法 synchronizedList 保证 list 是同步线程安全的

  • 代码修改2:Collections实现
/**
 * Collections实现:list集合线程安全
 */
public class ThreadDemo4 {
    public static void main(String[] args) {
        // 创建ArrayList集合
        List<String> list = Collections.synchronizedList(new ArrayList<>());
        
        for (int i = 0; i < 30; i++) {
            new Thread(()->{
                // 向集合中添加内容
                list.add(UUID.randomUUID().toString().substring(0,8));
                // 从集合中获取内容
                System.out.println(list);
            },String.valueOf(i)).start();
        }
    }
}
  • 没有并发修改异常
  • 查看方法源码
/**
 * Returns a synchronized (thread-safe) list backed by the specified
 * list.  In order to guarantee serial access, it is critical that
 * <strong>all</strong> access to the backing list is accomplished
 * through the returned list.<p>
 *
 * It is imperative that the user manually synchronize on the returned
 * list when iterating over it:
 * <pre>
 *  List list = Collections.synchronizedList(new ArrayList());
 *      ...
 *  synchronized (list) {
 *      Iterator i = list.iterator(); // Must be in synchronized block
 *      while (i.hasNext())
 *          foo(i.next());
 *  }
 * </pre>
 * Failure to follow this advice may result in non-deterministic behavior.
 *
 * <p>The returned list will be serializable if the specified list is
 * serializable.
 *
 * @param  <T> the class of the objects in the list
 * @param  list the list to be "wrapped" in a synchronized list.
 * @return a synchronized view of the specified list.
 */
public static <T> List<T> synchronizedList(List<T> list) {
    return (list instanceof RandomAccess ?
            new SynchronizedRandomAccessList<>(list) :
            new SynchronizedList<>(list));
}

2.4 解决方案:CopyOnWriteArrayList

首先我们对 CopyOnWriteArrayList 进行学习,其特点如下:
它相当于线程安全的 ArrayList。和 ArrayList 一样,它是个可变数组;但是和ArrayList 不同的时,它具有以下特性:

  1. 它最适合于具有以下特征的应用程序:List 大小通常保持很小,只读操作远多
    于可变操作,需要在遍历期间防止线程间的冲突。
  2. 它是线程安全的。
  3. 因为通常需要复制整个基础数组,所以可变操作(add()、set() 和 remove()
    等等)的开销很大。
  4. 迭代器支持 hasNext(), next()等不可变操作,但不支持可变 remove()等操作。
  5. 使用迭代器进行遍历的速度很快,并且不会与其他线程发生冲突。在构造迭代器时,迭代器依赖于不变的数组快照。

  • 思想和原理
  1. 独占锁效率低:采用读写分离思想解决
  2. 写线程获取到锁,其他写线程阻塞
  3. 复制思想:当我们往一个容器添加元素的时候,不直接往当前容器添加,而是先将当前容器进行 Copy,复制出一个新的容器,然后新的容器里添加元素,添加完元素之后,再将原容器的引用指向新的容器
    这就是 CopyOnWriteArrayList 的思想和原理。就是拷贝一份。
  • 代码修改3:CopyOnWriteArrayList实现
/**
 * CopyOnWriteArrayList实现:list集合线程安全
 */
public class ThreadDemo4 {
    public static void main(String[] args) {
        // 创建ArrayList集合
        List<String> list = new CopyOnWriteArrayList<>();
        
        for (int i = 0; i < 30; i++) {
            new Thread(()->{
                // 向集合中添加内容
                list.add(UUID.randomUUID().toString().substring(0,8));
                // 从集合中获取内容
                System.out.println(list);
            },String.valueOf(i)).start();
        }
    }
}
  • 没有线程安全问题
  • 原因分析(重点):动态数组与线程安全

下面从“动态数组”和“线程安全”两个方面进一步对CopyOnWriteArrayList 的原理进行说明

  • “动态数组”机制
  • 它内部有个“volatile 数组”(array)来保持数据。在“添加/修改/删除”数据时,都会新建一个数组,并将更新后的数据拷贝到新建的数组中,最后再将该数组赋值给“volatile 数组”, 这就是它叫做CopyOnWriteArrayList 的原因
  • 由于它在“添加/修改/删除”数据时,都会新建数组,所以涉及到修改数据的操作,CopyOnWriteArrayList 效率很低;但是单单只是进行遍历查找的话,效率比较高。
  • “线程安全”机制
  • 通过 volatile 和互斥锁来实现的
  • 通过“volatile 数组”来保存数据的。一个线程读取 volatile 数组时,总能看到其它线程对该 volatile 变量最后的写入;就这样,通过 volatile 提供了“读取到的数据总是最新的”这个机制的保证
  • 通过互斥锁来保护数据。在“添加/修改/删除”数据时,会先“获取互斥锁”,再修改完毕之后,先将数据更新到“volatile 数组”中,然后再“释放互斥锁”,就达到了保护数据的目的

3 HashSet集合线程不安全

3.1 HashSet集合操作Demo

  • 代码演示
/**
 * HashSet集合线程不安全
 */
public class ThreadDemo4 {
    public static void main(String[] args) {
        Set<String> set = new HashSet<>();
        for (int i = 0; i < 30; i++) {
            new Thread(()->{
                // 想集合添加内容
                set.add(UUID.randomUUID().toString().substring(0,8));
                // 从集合获取内容
                System.out.println(set);
            },String.valueOf(i)).start();
        }
    }
}
  • 运行结果
    在这里插入图片描述

  • 异常内容
    java.util.ConcurrentModificationException

  • 问题:为什么会出现并发修改异常
    查看HashSet的add方法源码:

/**
 * Adds the specified element to this set if it is not already present.
 * More formally, adds the specified element <tt>e</tt> to this set if
 * this set contains no element <tt>e2</tt> such that
 * <tt>(e==null&nbsp;?&nbsp;e2==null&nbsp;:&nbsp;e.equals(e2))</tt>.
 * If this set already contains the element, the call leaves the set
 * unchanged and returns <tt>false</tt>.
 *
 * @param e element to be added to this set
 * @return <tt>true</tt> if this set did not already contain the specified
 * element
 */
public boolean add(E e) {
    return map.put(e, PRESENT)==null;
}

那么我们如何去解决Set类型的线程安全问题?

3.2 解决方案:Collections

Collections 提供了方法 synchronizedSet保证 list 是同步线程安全的

  • 代码修改1:Collections实现
/**
 * Collections实现:HashSet集合线程安全
 */
public class ThreadDemo4 {
    public static void main(String[] args) {
        Set<String> set = Collections.synchronizedSet(new HashSet<>());
        for (int i = 0; i < 30; i++) {
            new Thread(()->{
                // 想集合添加内容
                set.add(UUID.randomUUID().toString().substring(0,8));
                // 从集合获取内容
                System.out.println(set);
            },String.valueOf(i)).start();
        }
    }
}
  • 没有并发修改异常
  • 查看方法源码
/**
* Returns a synchronized (thread-safe) set backed by the specified
* set.  In order to guarantee serial access, it is critical that
* <strong>all</strong> access to the backing set is accomplished
* through the returned set.<p>
*
* It is imperative that the user manually synchronize on the returned
* set when iterating over it:
* <pre>
*  Set s = Collections.synchronizedSet(new HashSet());
*      ...
*  synchronized (s) {
*      Iterator i = s.iterator(); // Must be in the synchronized block
*      while (i.hasNext())
*          foo(i.next());
*  }
* </pre>
* Failure to follow this advice may result in non-deterministic behavior.
*
* <p>The returned set will be serializable if the specified set is
* serializable.
*
* @param  <T> the class of the objects in the set
* @param  s the set to be "wrapped" in a synchronized set.
* @return a synchronized view of the specified set.
*/
public static <T> Set<T> synchronizedSet(Set<T> s) {
  return new SynchronizedSet<>(s);
}

3.3 解决方案:CopyOnWriteArraySet

  • 代码修改2:CopyOnWriteArraySet实现
/**
 * CopyOnWriteArraySet实现:HashSet集合线程安全
 */
public class ThreadDemo4 {
    public static void main(String[] args) {
        Set<String> set = new CopyOnWriteArraySet<>();
        for (int i = 0; i < 30; i++) {
            new Thread(()->{
                // 想集合添加内容
                set.add(UUID.randomUUID().toString().substring(0,8));
                // 从集合获取内容
                System.out.println(set);
            },String.valueOf(i)).start();
        }
    }
}
  • 没有线程安全问题
  • 实现原理
  1. 读操作无锁:
  • CopyOnWriteArraySet 的读操作(如 contains、iterator 等)不需要加锁,因为读操作总是基于当前的数组快照进行,不会受到写操作的影响。
  1. 写操作加锁并复制
  • 当进行写操作(如 add、remove 等)时,CopyOnWriteArraySet 会先获取锁,然后创建底层数组的新副本,在新副本上进行修改操作,最后将新副本替换原来的数组。
  • 由于写操作是在新副本上进行的,因此不会影响正在进行读操作的线程,从而保证了线程安全。
  1. 迭代器安全
  • CopyOnWriteArraySet 的迭代器是“快照”迭代器,它基于创建迭代器时的数组快照进行遍历,因此不会抛出ConcurrentModificationException。
  • 即使迭代器创建后集合发生了修改,迭代器仍然会基于创建时的快照进行遍历,不会受到后续修改的影响。

4 HashMap集合线程不安全

4.1 HasgMap集合操作Demo

  • 代码演示
/**
 * HashMap集合线程不安全
 */
public class ThreadDemo4 {
    public static void main(String[] args) {
        //演示HashMap
        Map<String,String> set = new HashMap<>();
        for (int i = 0; i < 30; i++) {
            String key = String.valueOf(i);
            new Thread(()->{
                // 想集合添加内容
                set.put(key,UUID.randomUUID().toString().substring(0,8));
                // 从集合获取内容
                System.out.println(set);
            },String.valueOf(i)).start();
        }
    }
}
  • 运行结果
    在这里插入图片描述

  • 异常内容
    java.util.ConcurrentModificationException

  • 问题:为什么会出现并发修改异常
    查看HashMap的put方法源码:

 /**
  * Associates the specified value with the specified key in this map.
  * If the map previously contained a mapping for the key, the old
  * value is replaced.
  *
  * @param key key with which the specified value is to be associated
  * @param value value to be associated with the specified key
  * @return the previous value associated with <tt>key</tt>, or
  *         <tt>null</tt> if there was no mapping for <tt>key</tt>.
  *         (A <tt>null</tt> return can also indicate that the map
  *         previously associated <tt>null</tt> with <tt>key</tt>.)
  */
 public V put(K key, V value) {
     return putVal(hash(key), key, value, false, true);
 }

那么我们如何去解决 Map 类型的线程安全问题?

4.2 解决方案:HashTable

  • 代码修改1:HashTable实现
/**
 * HashTable实现:HashMap集合线程安全
 */
public class ThreadDemo4 {
    public static void main(String[] args) {
        //演示HashMap
        Map<String,String> set = new HashTable<>();
        for (int i = 0; i < 30; i++) {
            String key = String.valueOf(i);
            new Thread(()->{
                // 想集合添加内容
                set.put(key,UUID.randomUUID().toString().substring(0,8));
                // 从集合获取内容
                System.out.println(set);
            },String.valueOf(i)).start();
        }
    }
}
  • 现在没有运行出现并发异常,为什么?
    查看 HashTable 的 put方法
/**
 * Maps the specified <code>key</code> to the specified
 * <code>value</code> in this hashtable. Neither the key nor the
 * value can be <code>null</code>. <p>
 *
 * The value can be retrieved by calling the <code>get</code> method
 * with a key that is equal to the original key.
 *
 * @param      key     the hashtable key
 * @param      value   the value
 * @return     the previous value of the specified key in this hashtable,
 *             or <code>null</code> if it did not have one
 * @exception  NullPointerException  if the key or value is
 *               <code>null</code>
 * @see     Object#equals(Object)
 * @see     #get(Object)
 */
public synchronized V put(K key, V value) {
    // Make sure the value is not null
    if (value == null) {
        throw new NullPointerException();
    }

    // Makes sure the key is not already in the hashtable.
    Entry<?,?> tab[] = table;
    int hash = key.hashCode();
    int index = (hash & 0x7FFFFFFF) % tab.length;
    @SuppressWarnings("unchecked")
    Entry<K,V> entry = (Entry<K,V>)tab[index];
    for(; entry != null ; entry = entry.next) {
        if ((entry.hash == hash) && entry.key.equals(key)) {
            V old = entry.value;
            entry.value = value;
            return old;
        }
    }

    addEntry(hash, key, value, index);
    return null;
}

4.2 解决方案:Collections

  • 代码修改2:Collections实现
/**
 * Collections实现:HashMap集合线程安全
 */
public class ThreadDemo4 {
    public static void main(String[] args) {
        //演示HashMap
        Map<String,String> set = Collections.synchronizedMap(new HashMap<>());
        for (int i = 0; i < 30; i++) {
            String key = String.valueOf(i);
            new Thread(()->{
                // 想集合添加内容
                set.put(key,UUID.randomUUID().toString().substring(0,8));
                // 从集合获取内容
                System.out.println(set);
            },String.valueOf(i)).start();
        }
    }
}
  • 没有并发修改异常
  • 查看方法源码
 /**
  * Returns a synchronized (thread-safe) map backed by the specified
  * map.  In order to guarantee serial access, it is critical that
  * <strong>all</strong> access to the backing map is accomplished
  * through the returned map.<p>
  *
  * It is imperative that the user manually synchronize on the returned
  * map when iterating over any of its collection views:
  * <pre>
  *  Map m = Collections.synchronizedMap(new HashMap());
  *      ...
  *  Set s = m.keySet();  // Needn't be in synchronized block
  *      ...
  *  synchronized (m) {  // Synchronizing on m, not s!
  *      Iterator i = s.iterator(); // Must be in synchronized block
  *      while (i.hasNext())
  *          foo(i.next());
  *  }
  * </pre>
  * Failure to follow this advice may result in non-deterministic behavior.
  *
  * <p>The returned map will be serializable if the specified map is
  * serializable.
  *
  * @param <K> the class of the map keys
  * @param <V> the class of the map values
  * @param  m the map to be "wrapped" in a synchronized map.
  * @return a synchronized view of the specified map.
  */
 public static <K,V> Map<K,V> synchronizedMap(Map<K,V> m) {
     return new SynchronizedMap<>(m);
 }

4.3 解决方案:ConcurrentHashMap

  • 代码修改3:CopyOnWriteHashMap实现
/**
 *CopyOnWriteHashMap实现:HashMap集合线程安全
 */
public class ThreadDemo4 {
    public static void main(String[] args) {
        //演示HashMap
        Map<String,String> set = new ConcurrentHashMap<>();
        for (int i = 0; i < 30; i++) {
            String key = String.valueOf(i);
            new Thread(()->{
                // 想集合添加内容
                set.put(key,UUID.randomUUID().toString().substring(0,8));
                // 从集合获取内容
                System.out.println(set);
            },String.valueOf(i)).start();
        }
    }
}
  • 没有线程安全问题
  • 实现原理
  1. 读操作无锁:
  • 读操作(如 get、containsKey 等)不需要加锁,因为读操作总是基于当前的 HashMap 快照进行,不会受到写操作的影响。
  1. 写操作加锁并复制:
  • 当进行写操作(如 put、remove 等)时,CopyOnWriteHashMap 会先获取锁,然后创建底层 HashMap 的新副本,在新副本上进行修改操作,最后将新副本替换原来的 HashMap。
  • 由于写操作是在新副本上进行的,因此不会影响正在进行读操作的线程,从而保证了线程安全。
  1. 迭代器安全:
  • CopyOnWriteHashMap 的迭代器是“快照”迭代器,它基于创建迭代器时的 HashMap 快照进行遍历,因此不会抛出 ConcurrentModificationException。
  • 即使迭代器创建后集合发生了修改,迭代器仍然会基于创建时的快照进行遍历,不会受到后续修改的影响。

5 总结

  1. 线程安全与线程不安全集合
    集合类型中存在线程安全与线程不安全的两种,常见例如:
    ArrayList ----- Vector
    HashMap -----HashTable
    但是以上都是通过 synchronized 关键字实现,效率较低
  2. Collections 构建的线程安全集合
  3. java.util.concurrent 并发包下
    CopyOnWriteArrayList、CopyOnWriteArraySet 类型,通过动态数组与线程安全两个方面保证线程安全

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2178143.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

铺铜修改后自动重铺

很多初学者对于敷铜操作感到比较麻烦&#xff1a;为什么每次打过孔&#xff0c;修改走线后都需要手动右击-重新修改敷铜。如何提升layout的效率&#xff1f; 版本&#xff1a;Altium Designer 21.9.2 首先&#xff0c;点击面板右边的小齿轮&#xff0c;进入设置 接下来&#…

9.29学习

1.线上问题rebalance 因集群架构变动导致的消费组内重平衡&#xff0c;如果kafka集内节点较多&#xff0c;比如数百个&#xff0c;那重平衡可能会耗时导致数分钟到数小时&#xff0c;此时kafka基本处于不可用状态&#xff0c;对kafka的TPS影响极大 产生的原因 ①组成员数量发…

【C++并发入门】摄像头帧率计算和多线程相机读取(上):并发基础概念和代码实现

前言 高帧率摄像头往往应用在很多opencv项目中&#xff0c;今天就来通过简单计算摄像头帧率&#xff0c;抛出一个单线程读取摄像头会遇到的问题&#xff0c;同时提出一种解决方案&#xff0c;使用多线程对摄像头进行读取。同时本文介绍了线程入门的基础知识&#xff0c;讲解了…

2-107 基于matlab的hsv空间双边滤波去雾图像增强算法

基于matlab的hsv空间双边滤波去雾图像增强算法&#xff0c;原始图像经过光照增强后&#xff0c;将RGB转成hsv&#xff0c;进行图像增强处理&#xff0c;使图像更加清晰。程序已调通&#xff0c;可直接运行。 下载源程序请点链接&#xff1a; 2-107 基于matlab的hsv空间双边滤…

“找不到emp.dll,无法继续执行代码”需要怎么解决呢?分享6个解决方法

在日常使用电脑玩游戏的过程中&#xff0c;我们可能会遇到一些错误提示&#xff0c;其中最常见的就是“emp.dll丢失”。那么&#xff0c;emp.dll到底是什么&#xff1f;它为什么会丢失&#xff1f;丢失后会对我们的电脑产生什么影响&#xff1f;本文将为您详细解析emp.dll的概念…

超详细的华为ICT大赛报名流程

1、访问华为人才在线官网&#xff0c;点击右上角“登录/注册“&#xff0c;登录华为账号。 报名链接&#xff1a; https://e.huawei.com/cn/talent/cert/#/careerCert?navTypeauthNavKey ▲如已有华为Uniportal账号&#xff0c;完成实名认证后方可报名大赛。 ▲如没有华为…

【有啥问啥】具身智能(Embodied AI):人工智能的新前沿

具身智能&#xff08;Embodied AI&#xff09;&#xff1a;人工智能的新前沿 引言 在人工智能&#xff08;AI&#xff09;的进程中&#xff0c;具身智能&#xff08;Embodied AI&#xff09;正逐渐成为研究与应用的焦点。具身智能不仅关注于机器的计算能力&#xff0c;更强调…

需求5:增加一个按钮

在之前的几个需求中&#xff0c;我们逐步从修改字段到新增字段&#xff0c;按部就班地完成了相关工作。通过最近的文章&#xff0c;不难看出我目前正在处理前端的“未完成”和“已完成”按钮。借此机会&#xff0c;我决定趁热打铁&#xff0c;重新梳理一下之前关于按钮实现的需…

4、MapReduce编程实践

目录 1、创建文件2、启动HDFS3、启动eclipse 创建项目并导入jar包file->new->java project导入jar包finish 4、编写Java应用程序5、编译打包应用程序&#xff08;1&#xff09;查看直接运行结果&#xff08;2&#xff09;打包程序&#xff08;3&#xff09;查看 JAR 包是…

软硬协同方案破解IT瓶颈,龙蜥衍生版KOS助力内蒙古大学成功迁移10+业务软件 | 龙蜥案例

2024 云栖大会上&#xff0c;龙蜥社区发布了《龙蜥操作系统生态用户实践精选 V2》&#xff0c;为面临 CentOS 迁移的广大用户提供成熟实践样板。截至目前&#xff0c;阿里云、浪潮信息、中兴通讯 | 新支点、移动、联通、龙芯、统信软件等超 12 家厂商基于龙蜥操作系统发布商业衍…

【在Linux世界中追寻伟大的One Piece】命名管道

目录 1 -> 命名管道 1.1 -> 创建一个命名管道 1.2 -> 匿名管道与命名管道的区别 1.3 -> 命名管道的打开规则 1.4 -> 例子 1 -> 命名管道 管道应用的一个限制就是只能在具有共同祖先(具有亲缘关系)的进程间通信。如果我们想在不相关的进程之间交换数据&…

串行化执行、并行化执行

文章目录 1、串行化执行2、并行化测试&#xff08;多线程环境&#xff09;3、任务的执行是异步的&#xff0c;但主程序的继续执行是同步的 可以将多个任务编排为并行和串行化执行。 也可以处理编排的多个任务的异常&#xff0c;也可以返回兜底数据。 1、串行化执行 顺序执行、…

C++类和对象(下) 初始化列表 、static成员、友元、内部类等等

1.再探构造函数 之前使用构造函数时都是在函数体内初始化成员变量&#xff0c;还有一种构造函数的用法&#xff0c;叫做初始化列表&#xff1b;那么怎么使用呢&#xff1f; 使用方法用冒号开始(" : ")要写多个就用逗号(" , ")隔开数据成队列每个成员变量后…

DC00023基于jsp+MySQL新生报到管理系统

1、项目功能演示 DC00023基于jsp新生报到管理系统java webMySQL新生管理系统 2、项目功能描述 基于jspMySQL新生报到管理系统项目分为学生、辅导员、财务处和系统管理员四个角色。 2.1 学生功能 1、系统登录 2、校园新闻、报到流程、学校简介、在线留言、校园风光、入校须知…

解决Qt每次修改代码后首次运行崩溃,后几次不崩溃问题

在使用unique_ptr声明成员变量后&#xff0c;我习惯性地在初始化构造列表中进行如下构造&#xff1a; 注意看&#xff0c;我将m_menuBtnGroup的父类指定为ui->center_menu_widget&#xff0c;这便是导致崩溃的根本原因&#xff0c;解决办法便是先用this初始化&#xff0c;后…

pdf页面尺寸裁减

1、编辑pdf 2、点击裁减页面&#xff0c;并在空白区域双击裁减 3、输入裁减数据&#xff1a;

calibre-web浏览器标题icon修改

calibre-web浏览器标题icon修改 Windows安装calibre-web&#xff0c;Python-CSDN博客文章浏览阅读537次&#xff0c;点赞10次&#xff0c;收藏11次。pip install calibreweb报错&#xff1a;error: Microsoft Visual C 14.0 or greater is required. Get it with "Microso…

Springboot中基于注解实现公共字段自动填充

1.使用场景 当我们有大量的表需要管理公共字段&#xff0c;并且希望提高开发效率和确保数据一致性时&#xff0c;使用这种自动填充方式是很有必要的。它可以达到一下作用 统一管理数据库表中的公共字段&#xff1a;如创建时间、修改时间、创建人ID、修改人ID等&#xff0c;这些…

视频剪辑软件哪个好?剪辑更高效用这些

众所周知&#xff0c;视频已经成为我们记录生活、表达自我的重要方式。 无论是制作旅行Vlog&#xff0c;还是剪辑短片分享故事&#xff0c;优秀的视频剪辑软件是让创意变为现实的利器。 那么&#xff0c;如何在众多免费软件中做出明智选择&#xff0c;成为剪辑高手呢&#xf…

通信工程学习:什么是SISO单入单出

SISO&#xff1a;单入单出 SISO&#xff0c;即单输入单输出&#xff08;Single-Input Single-Output&#xff09;系统&#xff0c;也被称为单变量系统。在这种系统中&#xff0c;输入量与输出量各为一个&#xff0c;是控制理论中的一个基本概念。以下是对SISO系统的详细解释&am…