您当前的位置: 首页 >  Java

彭世瑜

暂无认证

  • 1浏览

    0关注

    2791博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Java:原子操作类AtomicInteger代码示例

彭世瑜 发布时间:2021-01-05 17:45:13 ,浏览量:1

package com.demo.atomic;

import java.util.concurrent.atomic.AtomicInteger;

public class AtomicDemo {
    private static int count = 0;
    private static int synchronizedCount = 0;
    private static AtomicInteger atomicCount = new AtomicInteger();

    public static synchronized void addCount() {
        synchronizedCount++;
    }

    public static void main(String[] args) {

        // 创建5个线程
        Thread[] threads = new Thread[5];

        for (int i = 0; i  {
                for (int j = 0; j             
关注
打赏
1665367115
查看更多评论
0.1974s