任何人都可以在java中为我提供一个很好的小例子演示wait()和notify()功能.我试过下面的代码,但它没有显示我的预期.
public class WaitDemo {
int i = 10;
int display() {
System.out.println("Lexmark");
i++;
return i;
}
}
Run Code Online (Sandbox Code Playgroud)
public class ClassDemo1 extends Thread {
private WaitDemo wd = new WaitDemo();
public static void main(String[] args) {
ClassDemo1 cd1 = new ClassDemo1();
ClassDemo1 cd2 = new ClassDemo1();
cd1.setName("Europe");
cd2.setName("America");
cd1.start();
cd2.start();
}
synchronized void display() {
System.out.println("Hello");
notifyAll();
}
public void run() {
synchronized (this) {
try {
{
notify();
System.out.println("The thread is " + currentThread().getName());
wait();
System.out.println("The value is " …Run Code Online (Sandbox Code Playgroud) 在我的一个应用程序中,使用Web服务调用,它返回超过20种货币,例如
美元,日元,英镑,英镑,ESP,EGP等
现在我需要将每种货币转换为相关的符号.请建议我如何在我的应用程序中实现相同的功能.
谢谢
如何在liferay中弹出的会话不活动中添加一个注销链接?目前我们在该弹出窗口中没有任何超链接.我们只有警告消息.请帮我解决这个问题,因为我是liferay的新手.
谢谢,Sourav
今天我正在尝试下面的代码,并期望sysout的输出不同.
public class StringDemo {
public static void main(String[] args) {
String s1 = new String("Hi");
String s2 = new String("Hi");
System.out.println(s1.hashCode());
System.out.println(s2.hashCode());
}
}
Run Code Online (Sandbox Code Playgroud)
但我得到了同样的价值.任何人都可以解释一下这件事是如何运作的吗?
谢谢,Sourav