Loading services/tests/servicestests/src/com/android/server/locksettings/LockSettingsStorageTests.java +6 −10 Original line number Diff line number Diff line Loading @@ -122,20 +122,18 @@ public class LockSettingsStorageTests extends AndroidTestCase { } public void testKeyValue_Concurrency() { final Object monitor = new Object(); final CountDownLatch latch = new CountDownLatch(1); List<Thread> threads = new ArrayList<>(); for (int i = 0; i < 100; i++) { final int threadId = i; threads.add(new Thread("testKeyValue_Concurrency_" + i) { @Override public void run() { synchronized (monitor) { try { monitor.wait(); latch.await(); } catch (InterruptedException e) { return; } } mStorage.writeKeyValue("key", "1 from thread " + threadId, 0); mStorage.readKeyValue("key", "default", 0); mStorage.writeKeyValue("key", "2 from thread " + threadId, 0); Loading @@ -151,9 +149,7 @@ public class LockSettingsStorageTests extends AndroidTestCase { threads.get(i).start(); } mStorage.writeKeyValue("key", "initalValue", 0); synchronized (monitor) { monitor.notifyAll(); } latch.countDown(); joinAll(threads, 10000); assertEquals('5', mStorage.readKeyValue("key", "default", 0).charAt(0)); mStorage.clearCache(); Loading Loading
services/tests/servicestests/src/com/android/server/locksettings/LockSettingsStorageTests.java +6 −10 Original line number Diff line number Diff line Loading @@ -122,20 +122,18 @@ public class LockSettingsStorageTests extends AndroidTestCase { } public void testKeyValue_Concurrency() { final Object monitor = new Object(); final CountDownLatch latch = new CountDownLatch(1); List<Thread> threads = new ArrayList<>(); for (int i = 0; i < 100; i++) { final int threadId = i; threads.add(new Thread("testKeyValue_Concurrency_" + i) { @Override public void run() { synchronized (monitor) { try { monitor.wait(); latch.await(); } catch (InterruptedException e) { return; } } mStorage.writeKeyValue("key", "1 from thread " + threadId, 0); mStorage.readKeyValue("key", "default", 0); mStorage.writeKeyValue("key", "2 from thread " + threadId, 0); Loading @@ -151,9 +149,7 @@ public class LockSettingsStorageTests extends AndroidTestCase { threads.get(i).start(); } mStorage.writeKeyValue("key", "initalValue", 0); synchronized (monitor) { monitor.notifyAll(); } latch.countDown(); joinAll(threads, 10000); assertEquals('5', mStorage.readKeyValue("key", "default", 0).charAt(0)); mStorage.clearCache(); Loading