upload android base code part3
This commit is contained in:
parent
71b83c22f1
commit
b9e30e05b1
15122 changed files with 2089659 additions and 0 deletions
2
android/art/test/002-sleep/expected.txt
Normal file
2
android/art/test/002-sleep/expected.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
Sleeping 1000 msec...
|
||||
Done sleeping
|
3
android/art/test/002-sleep/info.txt
Normal file
3
android/art/test/002-sleep/info.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
Test that Thread.sleep() operates reasonably. This test is actually
|
||||
mostly meant as an easy thing to modify in order to test other things
|
||||
in an ad-hoc way.
|
22
android/art/test/002-sleep/src/Main.java
Normal file
22
android/art/test/002-sleep/src/Main.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
public class Main {
|
||||
static public void main(String[] args) throws Exception {
|
||||
int millis = 1000;
|
||||
|
||||
if (args.length > 1) {
|
||||
millis = Integer.parseInt(args[1]);
|
||||
}
|
||||
|
||||
System.out.println("Sleeping " + millis + " msec...");
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
Thread.sleep(millis);
|
||||
long elapsed = System.currentTimeMillis() - start;
|
||||
long offBy = Math.abs(elapsed - millis);
|
||||
|
||||
System.out.println("Done sleeping");
|
||||
|
||||
if (offBy > 250) {
|
||||
System.out.println("Actually slept about " + elapsed + " msec...");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue