如何在线程间通信中调用特定线程?
在下面的程序中,我有两个线程t1和t2.
当我称之为t1.notify()加薪:
Exception in thread "Thread-1" java.lang.IllegalMonitorStateException
at java.lang.Object.notify(Native Method)
at Shared.methodTwo(NotifyThread.java:43)
at Thread2.run(NotifyThread.java:77)
Error
Run Code Online (Sandbox Code Playgroud)
class Shared {
Thread1 t1 ;
Thread2 t2 ;
void ThreadInit( Thread1 t1 , Thread2 t2 ) {
this.t1 = t1 ;
this.t2 = t2 ;
}
synchronized void methodOne()
{
Thread t = Thread.currentThread();
System.out.println(t.getName()+" is relasing the lock and going to wait");
try
{
wait(); //releases the lock of this object and waits
}
catch (InterruptedException …Run Code Online (Sandbox Code Playgroud) #include<stdio.>
int main() {
signed x;
unsigned y;
x = 10 +- 10u + 10u +- 10;
y = x;
if(x==y)
printf("%d %d",x,y);
else if(x!=y)
printf("%u %u",x,y);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我无法理解上述程序的流程.请解释编译器如何-10u视为默认值.从我的理解10u是无符号的,但在这个程序中它自动将其转换为-10.
http://www.cquestions.com/2012/02/data-type-questions-in-c.html,问题编号.3.