Forgotten

This commit is contained in:
hyb1996
2017-02-20 23:37:47 +08:00
parent 40d6285bed
commit 676ca14aca
17 changed files with 375 additions and 35 deletions

View File

@@ -8,9 +8,32 @@ import org.junit.Test;
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
private int i = 0;
@Test
public void testSync() throws Exception {
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
synchronized (this) {
i++;
}
}
}
}).start();
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
synchronized (this) {
System.out.println(i);
}
}
}
}).start();
}