文件名称:thread
-
所属分类:
- 标签属性:
- 上传时间:2012-11-16
-
文件大小:23.86kb
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
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/.project
thread/src/thread1/Thread_2.java
thread/src/thread2/Thread_2.java
thread/src/thread3/Thread_2.java
thread/src/thread4/Thread_2.java
thread/src/thread_static_1/Thread_2.java
thread/src/thread3_2/Thread_2.java
thread/src/thread_static_1_2/Thread_2.java
thread/src/thread_static_1_2_2/Thread_2.java
thread/src/thread_lock_be_modify/Thread_lock_be_modify.java
thread/bin/thread_static_1_2_2/TestThread.class
thread/bin/thread_static_1_2_2/Thread_2.class
thread/bin/thread_static_1_2_2/ThreadA.class
thread/bin/thread_static_1_2/TestThread.class
thread/bin/thread_static_1_2/Thread_2.class
thread/bin/thread_static_1_2/ThreadA.class
thread/bin/thread_static_1/ThreadA.class
thread/bin/thread_static_1/TestThread.class
thread/bin/thread_static_1/Thread_2.class
thread/bin/thread_lock_be_modify/Thread_lock_be_modify$Thread_lock_be_modifyHolder.class
thread/bin/thread_lock_be_modify/Thread_lock_be_modify.class
thread/bin/thread4/ThreadA.class
thread/bin/thread4/Thread_2.class
thread/bin/thread4/TestThread.class
thread/bin/thread3_2/Thread_2.class
thread/bin/thread3_2/ThreadA.class
thread/bin/thread3_2/TestThread.class
thread/bin/thread3/ThreadA.class
thread/bin/thread3/Thread_2.class
thread/bin/thread3/TestThread.class
thread/bin/thread2/TestThread.class
thread/bin/thread2/Thread_2.class
thread/bin/thread2/ThreadA.class
thread/bin/thread1/ThreadA.class
thread/bin/thread1/TestThread.class
thread/bin/thread1/Thread_2.class
thread/.classpath
thread/src/thread1
thread/src/thread2
thread/src/thread3
thread/src/thread4
thread/src/thread_static_1
thread/src/thread3_2
thread/src/thread_static_1_2
thread/src/thread_static_1_2_2
thread/src/thread_lock_be_modify
thread/bin/thread_static_1_2_2
thread/bin/thread_static_1_2
thread/bin/thread_static_1
thread/bin/thread_lock_be_modify
thread/bin/thread4
thread/bin/thread3_2
thread/bin/thread3
thread/bin/thread2
thread/bin/thread1
thread/src
thread/bin
thread
thread/src/thread1/Thread_2.java
thread/src/thread2/Thread_2.java
thread/src/thread3/Thread_2.java
thread/src/thread4/Thread_2.java
thread/src/thread_static_1/Thread_2.java
thread/src/thread3_2/Thread_2.java
thread/src/thread_static_1_2/Thread_2.java
thread/src/thread_static_1_2_2/Thread_2.java
thread/src/thread_lock_be_modify/Thread_lock_be_modify.java
thread/bin/thread_static_1_2_2/TestThread.class
thread/bin/thread_static_1_2_2/Thread_2.class
thread/bin/thread_static_1_2_2/ThreadA.class
thread/bin/thread_static_1_2/TestThread.class
thread/bin/thread_static_1_2/Thread_2.class
thread/bin/thread_static_1_2/ThreadA.class
thread/bin/thread_static_1/ThreadA.class
thread/bin/thread_static_1/TestThread.class
thread/bin/thread_static_1/Thread_2.class
thread/bin/thread_lock_be_modify/Thread_lock_be_modify$Thread_lock_be_modifyHolder.class
thread/bin/thread_lock_be_modify/Thread_lock_be_modify.class
thread/bin/thread4/ThreadA.class
thread/bin/thread4/Thread_2.class
thread/bin/thread4/TestThread.class
thread/bin/thread3_2/Thread_2.class
thread/bin/thread3_2/ThreadA.class
thread/bin/thread3_2/TestThread.class
thread/bin/thread3/ThreadA.class
thread/bin/thread3/Thread_2.class
thread/bin/thread3/TestThread.class
thread/bin/thread2/TestThread.class
thread/bin/thread2/Thread_2.class
thread/bin/thread2/ThreadA.class
thread/bin/thread1/ThreadA.class
thread/bin/thread1/TestThread.class
thread/bin/thread1/Thread_2.class
thread/.classpath
thread/src/thread1
thread/src/thread2
thread/src/thread3
thread/src/thread4
thread/src/thread_static_1
thread/src/thread3_2
thread/src/thread_static_1_2
thread/src/thread_static_1_2_2
thread/src/thread_lock_be_modify
thread/bin/thread_static_1_2_2
thread/bin/thread_static_1_2
thread/bin/thread_static_1
thread/bin/thread_lock_be_modify
thread/bin/thread4
thread/bin/thread3_2
thread/bin/thread3
thread/bin/thread2
thread/bin/thread1
thread/src
thread/bin
thread
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.