collection/collection/src/test/java/androidx/collection/ArrayMapTest.java
/**
     * 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 {
                mMap.put(String.format("key %d", i++), "B_DONT_DO_THAT");
                if (i % 200 == 0) {
                    System.out.print(".");
                }
                if (i % 500 == 0) {
                    mMap.clear();
                    System.out.print("X");
                }
            } catch (ConcurrentModificationException e) {
                fail(e.getMessage());
            }
        }
    }
@ Test public void testNonConcurrentAccesses ( ) throws Exception { for ( int i = 0 ; i < 100000 ; i ++ ) { try { mMap . put ( String . format ( "key %d" , i ++ ) , "B_DONT_DO_THAT" ) ; if ( i % 200 == 0 ) { System . out . print ( "." ) ; } if ( i % 500 == 0 ) { mMap . clear ( ) ; System . out . print ( "X" ) ; } } catch ( ConcurrentModificationException e ) { fail ( e . getMessage ( ) ) ; } } }
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 .