package com.cxz.currency.test;
public class Testee implements Runnable {
Object lock = null;
public boolean runFlag = false;
public Testee(Object lock) {
this.lock = lock;
}
public void run() {
synchronized (lock) {
try {
if (!runFlag) {
lock.wait();
}
System.out.println("Hello" + Thread.currentThread().getName());
} catch (InterruptedException ex) {
}
}
}
public void start() {
Thread thread = new Thread(this);
thread.start();
}
}
package com.cxz.currency.test;
public class Main {
public void test() throws InterruptedException{
Object lock = new Object();
Testee[] ts = new Testee[2];
ts[0] = new Testee(lock);
ts[1] = new Testee(lock);
ts[0].start();
ts[1].start();
Thread.sleep(100);
synchronized (lock) {
lock.notify();
}
}
public static void main(String[] args) throws InterruptedException{
new Main().test();
}
}
In the Main::test() I created 2 threads which were block at the lock.wait and after the main thread sleeped 100 milliseconds call the lock.notify and the lock.notifyAll you could see the differences.
分享到:
相关推荐
C++与C#是两种广泛应用的编程语言,它们在很多方面都有显著的区别。本文将详细探讨这两种语言之间的主要差异,帮助开发者理解它们各自的特点。 1. 命名空间和成员访问: - C# 使用点号(.)来分隔命名空间、类以及...
Talk Show Differences Between China and America from the Perspective of the Form and Express.zip
The Differences Between Chinese and American Cultures from the Perspective of Politeness Utterances.zip
在IT领域,尤其是在企业软件开发中,理解不同的增强技术至关重要。本文将深入探讨EEWB(Enhancement Element Workbench)和BDT(Business Data Type)之间的差异,这两种工具都是用于SAP CRM系统中的对象扩展和定制...
英语与汉语的语言结构差异是一个复杂且广泛的话题,涉及语言学的多个层面。首先需要明确的是,任何两种语言之间的结构差异都是各自文化和思维模式差异的反映。这一点在英汉语言对比中尤为明显。...
标题:架构差异:IMX51与IMX53 描述:本文将深入解析由飞思卡尔半导体(Freescale Semiconductor)出品的IMX51与IMX53处理器之间的架构区别,这两款处理器均基于ARM Cortex-A8核心,旨在为多媒体应用提供高性能处理...
Employment-related differences between male and female school psychologists Psychulony in Ihe Schools Yollrme 31. July /994 EMPLOYMENT-RELATED DIFFERENCES BETWEEN MALE AND FEMALE SCHOOL ...
Differences between urban and rural school psychology: Training implications P \ i i h o l o ~ i in rhr Srhvolr I Y X I . l R . 191-196 DIFFERENCES BETWEEN URBAN AND RURAL SCHOOL PSYCHOLOGY: ...
### 最小二乘法与卡尔曼滤波的区别 在GPS导航系统和其他位置定位技术中,两种最常用的估计方法是最小二乘法(Least Squares, LS)和卡尔曼滤波(Kalman Filtering, KF)。这两种方法虽然表面上看起来有很大区别,但...
【标题】:初识SQL:SQL Server与Oracle之间的差异 【描述】:这份资料主要针对SQL初学者,尤其是从SQL Server环境转向Oracle的用户,详细介绍了两者在语法、功能和概念上的不同之处。 【标签】:SQL ...
S32K11x和S32K142微控制器(MCUs)是NXP半导体公司生产的两个系列的产品。虽然两者具有许多共通模块,但也存在一些显著差异,尤其是在核心架构、内存选项、外设配置、中断映射和软件迁移的兼容性等方面。...
Diagnostic differences between educationally handicapped and learning disabled students Pr~.rhulugv in the Schuul.r PPVT and MSCA with Autistic Children 469 1980. 17. 469-473 SCHOPLER, E. ...
Differences-between-LIN20-and-LIN21 (1)
Identification of statistically significant differences between scaled scores and psycholinguistic ages on the ITPA IDENTIFICATION OF STATISTICALIiY SIGNIFICANT DIFFERENCES BETWEEN SCALED SCORES ...
数据库系统概念课后习题答案
Philosophical differences between early childhood education and special education: Issues for school psychologists Psychology in Ihe Schools Volume 23, April 1986 PHILOSOPHICAL DIFFERENCES ...
《东西方饮食文化差异》 饮食,作为人类生活的基本需求之一,不仅是生理的满足,更是文化的体现。中国和西方在饮食习惯、食材选择、烹饪方式等方面存在着显著的文化差异,这些差异背后反映了各自的历史传统、哲学...
Significant differences between individual subtest scaled scores and average scaled scores on the Wechsler Preschool and Primary Scale of Intelligence-Revised Psychology in the Schools Volume 28. ...
Reliability and abnormality of differences between DTVP subtest scores 204 JAMES E. YSSELDYKE, DAVID A. SABATINO AND JOSEPH LAMANNA CONCLUSION A multitrait-multimethod matrix was used to ...