文件名称:thread
- 所属分类:
- JSP源码/Java
- 资源属性:
- [Java] [源码]
- 上传时间:
- 2012-11-26
- 文件大小:
- 24kb
- 下载次数:
- 0次
- 提 供 者:
- fir****
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
java 线程 静态锁,对象锁, synchronized 是锁方法还是锁对象?还是锁类?如何实现??
部分代码如下,
public static Object lock=new Object() //静态锁,锁类,不是锁对象了!!所以两个线程同时 运行两个 TestThread 的execute(
),也可以同步!!!
public void execute(){ //
synchronized(lock){ for(int i=0 i<20 i++){
try {
Thread.sleep(30)
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace()
}
System.out.println(Thread.currentThread().getName()+Thread.currentThread
().getName()+" "+i)
}
}
}
-
java 线程 静态锁,对象锁, synchronized 是锁方法还是锁对象?还是锁类?如何实现??
部分代码如下,
public static Object lock=new Object() //静态锁,锁类,不是锁对象了!!所以两个线程同时 运行两个 TestThread 的execute(
),也可以同步!!!
public void execute(){ //
synchronized(lock){ for(int i=0 i<20 i++){
try {
Thread.sleep(30)
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace()
}
System.out.println(Thread.currentThread().getName()+Thread.currentThread
().getName()+" "+i)
}
}
}
相关搜索: java线程
(系统自动生成,下载前可以参看下载内容)
下载文件列表
thread
......\.classpath
......\.project
......\bin
......\...\thread1
......\...\.......\TestThread.class
......\...\.......\ThreadA.class
......\...\.......\Thread_2.class
......\...\thread2
......\...\.......\TestThread.class
......\...\.......\ThreadA.class
......\...\.......\Thread_2.class
......\...\thread3
......\...\.......\TestThread.class
......\...\.......\ThreadA.class
......\...\.......\Thread_2.class
......\...\thread3_2
......\...\.........\TestThread.class
......\...\.........\ThreadA.class
......\...\.........\Thread_2.class
......\...\thread4
......\...\.......\TestThread.class
......\...\.......\ThreadA.class
......\...\.......\Thread_2.class
......\...\thread_lock_be_modify
......\...\.....................\Thread_lock_be_modify$Thread_lock_be_modifyHolder.class
......\...\.....................\Thread_lock_be_modify.class
......\...\thread_static_1
......\...\...............\TestThread.class
......\...\...............\ThreadA.class
......\...\...............\Thread_2.class
......\...\thread_static_1_2
......\...\.................\TestThread.class
......\...\.................\ThreadA.class
......\...\.................\Thread_2.class
......\...\thread_static_1_2_2
......\...\...................\TestThread.class
......\...\...................\ThreadA.class
......\...\...................\Thread_2.class
......\src
......\...\thread1
......\...\.......\Thread_2.java
......\...\thread2
......\...\.......\Thread_2.java
......\...\thread3
......\...\.......\Thread_2.java
......\...\thread3_2
......\...\.........\Thread_2.java
......\...\thread4
......\...\.......\Thread_2.java
......\...\thread_lock_be_modify
......\...\.....................\Thread_lock_be_modify.java
......\...\thread_static_1
......\...\...............\Thread_2.java
......\...\thread_static_1_2
......\...\.................\Thread_2.java
......\...\thread_static_1_2_2
......\...\...................\Thread_2.java
......\.classpath
......\.project
......\bin
......\...\thread1
......\...\.......\TestThread.class
......\...\.......\ThreadA.class
......\...\.......\Thread_2.class
......\...\thread2
......\...\.......\TestThread.class
......\...\.......\ThreadA.class
......\...\.......\Thread_2.class
......\...\thread3
......\...\.......\TestThread.class
......\...\.......\ThreadA.class
......\...\.......\Thread_2.class
......\...\thread3_2
......\...\.........\TestThread.class
......\...\.........\ThreadA.class
......\...\.........\Thread_2.class
......\...\thread4
......\...\.......\TestThread.class
......\...\.......\ThreadA.class
......\...\.......\Thread_2.class
......\...\thread_lock_be_modify
......\...\.....................\Thread_lock_be_modify$Thread_lock_be_modifyHolder.class
......\...\.....................\Thread_lock_be_modify.class
......\...\thread_static_1
......\...\...............\TestThread.class
......\...\...............\ThreadA.class
......\...\...............\Thread_2.class
......\...\thread_static_1_2
......\...\.................\TestThread.class
......\...\.................\ThreadA.class
......\...\.................\Thread_2.class
......\...\thread_static_1_2_2
......\...\...................\TestThread.class
......\...\...................\ThreadA.class
......\...\...................\Thread_2.class
......\src
......\...\thread1
......\...\.......\Thread_2.java
......\...\thread2
......\...\.......\Thread_2.java
......\...\thread3
......\...\.......\Thread_2.java
......\...\thread3_2
......\...\.........\Thread_2.java
......\...\thread4
......\...\.......\Thread_2.java
......\...\thread_lock_be_modify
......\...\.....................\Thread_lock_be_modify.java
......\...\thread_static_1
......\...\...............\Thread_2.java
......\...\thread_static_1_2
......\...\.................\Thread_2.java
......\...\thread_static_1_2_2
......\...\...................\Thread_2.java