collection/src/test/java/androidx/collection/SimpleArrayMapTest.java
@Test
    public void testNonConcurrentAccesses() throws Exception {
        for (int i = 0; i < 100000; i++) {
            try {
                map.put(String.format(Locale.US, "key %d", i++), "B_DONT_DO_THAT");
                if (i % 500 == 0) {
                    map.clear();
                }
            } catch (ConcurrentModificationException e) {
                System.err.println("Concurrent modification caught on single thread");
                e.printStackTrace();
                fail();
            }
        }
    }
/**
     * Check to make sure the same operations behave as expected in a single thread.
     */
Check to make sure the same operations behave as expected in a single thread.
Check to make sure the same operations behave as expected in a single thread .
@Test
    public void testNonConcurrentAccesses() throws Exception {
        for (int i = 0; i < 100000; i++) {
            try {
                map.put(String.format(Locale.US, "key %d", i++), "B_DONT_DO_THAT");
                if (i % 500 == 0) {
                    map.clear();
                }
            } catch (ConcurrentModificationException e) {
                System.err.println("Concurrent modification caught on single thread");
                e.printStackTrace();
                fail();
            }
        }
    }
@ Test public void testNonConcurrentAccesses ( ) throws Exception { for ( int i = 0 ; i < 100000 ; i ++ ) { try { map . put ( String . format ( Locale . US , "key %d" , i ++ ) , "B_DONT_DO_THAT" ) ; if ( i % 500 == 0 ) { map . clear ( ) ; } } catch ( ConcurrentModificationException e ) { System . err . println ( "Concurrent modification caught on single thread" ) ; e . printStackTrace ( ) ; fail ( ) ; } } }
Check to make sure the same operations behave as expected in a single thread.
Check to make sure the same operations behave as expected in a single thread .