- 浏览: 8662 次
- 性别:
- 来自: 北京
最新评论
文章列表
public class Contact
{
private String type;
private String name;
private String address;
private String city;
private String province;
private String postalcode;
private String country;
//增加一个country的属性: from
private String countryFrom;
private St ...
jdk动态代理和CGLIB动态代理的区别: jdk动态代理只能针对实现了接口的目标代理, CGLIB是针对类来实现动态代理,当没有实现接口的类需要代理时,就需要通过CGLIB来实现动态代理。jdk动态代理: User.java
public class User {
private String uname;
private String email;
public String getUname() {
return uname;
}
public void setUname(String uname) {
...
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
public class ThreadLocalTest {
private static Map<Thread, Integer> threadData = new HashMap<Thread, Integer>();
private static ThreadLocal<Integer> threadLocal = new ThreadLocal<Integer>();
/**
* 开启 ...
要求:
1、先主线程循环100次,
2、接着子线程循环10,
3、再主线程循环100次,
4、再子线程循环10,
如此反复50次
步骤:
1、创建一个业务类:
class Bussieser {
private boolean flag = true;
public synchronized void sub() {
if(!flag){
try {
this.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
for (int i = 1; i <= 10; ...
新建xml文件(users.xml):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<users>
<user id="u1">
<address>
<address>海淀</address>
</address>
<nickname>张三</nickname>
<username>zhangsan</userna ...
新建User类
@XmlRootElement(name="User")
public class User {
private int id;
private String username;
private String nickname;
private String password;
private Address address;
public int getId() {
return id;
}
public String getUsername() {
return username;
}
public String ...
建立一个学生类(Student.class):
public class Student {
private int id;
private String username;
private String password;
public int getId() {
return id;
}
public String getUsername() {
return username;
}
public String getPassword() {
return password;
}
public void setId(int id) {
this.id ...
二分查找数组必须为有序数组,查找速度比无序数组快,插入速度比无序数组慢。
查找次数为数组长度的开方。
方法:
public static int find(long searchKey) {
long[] arr = new long[100];
arr[0] = 11;
arr[1] = 22;
arr[2] = 33;
arr[3] = 44;
arr[4] = 55;
arr[5] = 66;
arr[6] = 77;
arr[7] = 88;
arr[8] = 99;
arr[9] = 100;
int countElems = 10;
...