Giter VIP home page Giter VIP logo

Comments (3)

fangjian0423 avatar fangjian0423 commented on June 29, 2024

I think this is a bug of https://github.com/nacos-group/nacos-spring-project and we will do it soon.

from nacos-spring-boot-project.

icc99 avatar icc99 commented on June 29, 2024

我这边也经常报这个错

from nacos-spring-boot-project.

chuntaojun avatar chuntaojun commented on June 29, 2024

The possible cause of the problem has been identified,you can try this code

public class DeferrNPE {

    private static LinkedList<String> list = new LinkedList<>();

    private static CountDownLatch latch = new CountDownLatch(3);
    private static CountDownLatch start = new CountDownLatch(3);

    private static class MyListener implements Runnable {

        @Override
        public void run() {
            start.countDown();
            try {
                start.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            list.add(String.valueOf(System.currentTimeMillis()));
            latch.countDown();
        }
    }

    public static void main(String[] args) {
        MyListener l1 = new MyListener();
        MyListener l2 = new MyListener();
        MyListener l3 = new MyListener();
        new Thread(l1).start();
        new Thread(l2).start();
        new Thread(l3).start();
        try {
            latch.await();
            Iterator<String> iterator = list.iterator();
            while (iterator.hasNext()) {
                System.out.println(iterator.next());
                iterator.remove();
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}

from nacos-spring-boot-project.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.