package com.jeetu.app.util;
import java.util.*;
public class test {
public static void main(String[] args) {
List linkedList = new LinkedList();
executeLogic(addContents(linkedList, "LinkedList"), displayContents(linkedList, "LinkedList")).start();
List arrayList = new ArrayList();
executeLogic(addContents(arrayList, "ArrayList"), displayContents(arrayList, "ArrayList")).start();
Set hashSet = new HashSet();
executeLogic(addContents(hashSet, "HashSet"), displayContents(hashSet, "HashSet")).start();
Set treeSet = new TreeSet();
executeLogic(addContents(treeSet, "TreeSet"), displayContents(treeSet, "TreeSet")).start();
}
static Thread executeLogic(final Thread t1, final Thread t2) {
Thread t = new Thread(new Runnable() {
public void run() {
while (true) {
try {
t1.start();
t1.join();
t2.start();
break;
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
});
return t;
}
static Thread addContents(final Collection e, final String type) {
Thread t = new Thread(new Runnable() {
public void run() {
long end;
long start = System.currentTimeMillis();
long limit = 5000000;
for (int index = 1; index <= limit; index++) {
e.add(index);
}
end = System.currentTimeMillis();
System.out.println("Write[" + type + "]: " + (end - start) + " ms.");
}
});
return t;
}
static Thread displayContents(final Collection e, final String type) {
Thread t = new Thread(new Runnable() {
public void run() {
long end;
long start = System.currentTimeMillis();
int total = 0;
Iterator i = e.iterator();
while (i.hasNext()) {
total = total + (Integer) i.next();
}
end = System.currentTimeMillis();
System.out.println("Read[" + type + "]: " + (end - start) + " ms ,Total = " + total + ".");
}
});
return t;
}
}
Result:
Write[ArrayList]: 12997 ms.
Write[LinkedList]: 13144 ms.
Read[ArrayList]: 185 ms ,Total = 1647668640.
Read[LinkedList]: 69 ms ,Total = 1647668640.
Write[HashSet]: 29986 ms.
Read[HashSet]: 69 ms ,Total = 1647668640.
Write[TreeSet]: 38823 ms.
Read[TreeSet]: 67 ms ,Total = 1647668640.
Process finished with exit code 0
Code:
This code can be used to get some interesting information about your phone and battery. It shows following 4 menus on screen:
Phone information
Battery information
Battery history
Usage statistics
*#*#4636#*#*
Code:
This code can be used for a factory data reset. It'll remove following things:
Google account settings stored in your phone
System and application data and settings
Downloaded applications
It'll NOT remove:
Current system software and bundled applications
SD card files e.g. photos, music files, etc.
*#*#7780#*#*
PS: Once you give this code, you get a prompt screen asking you to click on "Reset phone" button. So you get a chance to cancel your operation.
Read more...