This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Cloud Application Architecture Patterns: Designing, Building, and Modernizing for the Cloud and have Kyle Brown, Bobby Woolf and Joseph Yodor on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

without giving notify control comes back to print main

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in the example given below , I have not given notify yet control comes back and prints main.I thought notify is necessary.

class B implements Runnable
{
public void run()
{
for(int i=0;i<10;i++)
{
System.out.println ("Number="+i);
}
}
}

public class H
{
public static void main(String[] args)
{
B b1=new B();
Thread t1=new Thread(b1);
t1.start();

synchronized(t1)
{
try
{
t1.wait();
}
catch(InterruptedException ex)
{
ex.printStackTrace();
}
System.out.println ("main");
}

}
}
 
Ranch Hand
Posts: 814
Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can check following post it may help you Explaination given by author Henry Wong

https://coderanch.com/t/234368/threads/java/wait-without-notify

Regards
Ninad
reply
    Bookmark Topic Watch Topic
  • New Topic