@Test
    public void testConcurrentModify() throws InterruptedException {
        for (int i = 0; i < 10; i++) {
            RpcInvokeContext.getContext().put("" + i, "" + i);
        }

        CountDownLatch countDownLatch = new CountDownLatch(2);
        RpcInvokeContext mainContext = RpcInvokeContext.getContext();
        AtomicReference<RuntimeException> exceptionHolder = new AtomicReference<>();
        new Thread(() -> {
            countDownLatch.countDown();
            try {
                countDownLatch.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            long start = System.currentTimeMillis();
            try {
                while (System.currentTimeMillis() - start < 100) {
                    RpcInvokeContext.setContext(mainContext);
                }
            } catch (RuntimeException e) {
                exceptionHolder.set(e);
                throw e;
            }

        }).start();

        Map<String, String> headers = RpcInvokeContext.getContext().getCustomHeader();
        countDownLatch.countDown();
        countDownLatch.await();
        long start = System.currentTimeMillis();
        int i = 0;
        while (System.currentTimeMillis() - start < 100) {
            if (exceptionHolder.get() != null) {
                throw exceptionHolder.get();
            }
            headers.put("" + i, "" + i);
            i++;
        }
    }
@author <a href="mailto:zhanggeng.zg@antfin.com">GengZhang</a>
core/api/src/test/java/com/alipay/sofa/rpc/context/RpcInvokeContextTest.java