Thread Problem - (Thread Blocking Problems?)

Hi Friends
In my program while using thread i found a problem in this code .
In this whlie running the 'msg' was printen only after all 5 inputs are given .
why i was not getting output after one input.why the thread out was waiting for remaining threads input.
my code is
import java.io.*;
class MyThread extends Thread
  BufferedReader bin;
   MyThread()
     super();
     start();
   public void run()
      try
       bin=new BufferedReader(new InputStreamReader(System.in));
       String msg=bin.readLine();
       System.out.println(msg);
      catch(IOException e)
         System.out.println(e);
public class Threads
     public static void main(String args[])
          for(int i=0;i<5;i++)
            new MyThread();
}

Hi Friends
In my program while using thread i found a problem
em in this code .
In this whlie running the 'msg' was printen only
after all 5 inputs are given .
why i was not getting output after one input.why
hy the thread out was waiting for remaining threads
input.Probably because of how the scheduler was rotating among the threads while waiting for input and queueing up output.
When you call readLine, that thread blocks until a line is available. So it probably goes to the next thread's readLine, and so on. All threads are probably blocked waiting for input before you enter a single character.
Something inside the VM has to coordinate the interaction with the console, and between that and your threads, the out stuff just doesn't get a chance to display right away.
In general, you can't predict the order of execution of separate threads.

Similar Messages

  • Suddenly, I've been put on multiple threads over multiple firefox problems, which is filling up my inbox. How do I get out of these?

    Details? I posted a question about one problem (for which no answers have been offered, but that's okay) and somehow, I've become part of multiple threads about various firefox problems. I have no interest in any of these questions/problems.
    How do I get out of these threads? I get about 15-20 emails a day! Firefox is by far the worst community I've even been dragged into....

    Sorry you are having problems.
    Have a look at your settings in the dropdown from the username or https://support.mozilla.org/en-US/users/settings
    Not too sure what you could subscribe to accidentally that causes that behaviour though.
    It would be interesting to know what option caused all the email. If something has gone wrong and you are getting e-mails that you should not be getting we can refer this to the admins to look into. The Firefox sumo community certainly does not intentionally spam, and if you are having a problem lets find out more, because others may have a problem and not have reported it.

  • Problem in block based Query

    Respected Guru's
    I have a problem eith block bassed query.i have already used this block based query and it is working too.
    But here i am facing the the problem.why becuz i have used a global variable to pass value for execute it.
    and used 'set_block_property' to execute this query ..
    go_block('block name ')
    execute_query;
    But it si showing unable to perform the query..
    How i do this?? plez help me out...

    Dear...........
    There are some possible reasons.
    1- The items that are in data block , there is some field data is not database field and you set the property of this item is
    "Data Base Item" = 'Yes' , means this field is not in table.
    2- user right problem
    3- see the block property where set the property QUERY = NO\
    THX.

  • Could Not Sign In:  A server problem is blocking Apple ID sign in.  Try signing in later.

    After a successful iOS 5 upgrade to my iPhone 3GS, I began going through the setup wizard the phone takes you through upon initial use.  However, I'm unable to make it past the part where you are supposed to "Sign In with an Apple ID".  The steps to reproduce the problem are:
    Click "Sign In with an Apple ID".
    Per the "Have MobileMe and an ITunes Account?" instructions, I opt to type in my MobileMe e-mail address (e.g. [email protected]) and password.
    Click "Next".
    Specify birthday.
    Click "Next".
    Click "Agree".
    Click "Agree" on popup.
    A popup error is produced which reads "Could Not Sign In:  A server problem is blocking Apple ID sign in.  Try signing in later.".
    Click "OK" which takes you back to the initial sign in screen.
    I have tried logging in since 2am ET.  It is now 8:17am ET.  The server should not be down for over 6 hours.  Any ideas?
    Thanks in advance for any assistance offered!

    Hi Natalie,
    I was able to workaround this issue by clicking the "Skip" option on the first screen.  Afterwards, I went back and manually entered my me.com Apple ID in Settings | iCloud and my iTunes Apple ID in Settings | Store.  Doing it this way doesn't ask you to enter your birthday and I haven't yet found where that is supposed to be set.  However, everything appears to be working correctly without it.  Hope this helps!
    Brad

  • I am trying to activate my iPhone. I am seeing a message saying "a server problem is blocking Apple ID sign in. Try signing in later." What is this?

    I am trying to activate my new Verizon Iphone. I am getting a message saying "A server problem is blocking Apple ID sign in. Please try again later." What is this and it seems to be persisting.........can't activate my long awaited new phone!

    Hi Natalie,
    I was able to workaround this issue by clicking the "Skip" option on the first screen.  Afterwards, I went back and manually entered my me.com Apple ID in Settings | iCloud and my iTunes Apple ID in Settings | Store.  Doing it this way doesn't ask you to enter your birthday and I haven't yet found where that is supposed to be set.  However, everything appears to be working correctly without it.  Hope this helps!
    Brad

  • How do i restore my ipad from icloud if it keeps telling me a server problem is blocking Apple Id sign in

    help! I updated to iOS 6 and then my ipad had to be restored. After a day I finally got it to where I go start restoring it from icloud...now I get as far as trying to sign into my apple id and it says " a server problem is blocking apple id sign in"

    exactly my problem too. and i got it for christmas

  • Thread vs Non-Blocking - invoke thead

    Hi,
    My question related to Thread vs Non-Blocking IO used for network application. If my application needs to handle several thousands or even ten thousand connection simultaneously, did I little research, I concluded that instead of having 10,000 thread running (don't know even that number is possible), I should use NIO instead. My question is that, if I use NIO and fire up a thread everytime I had new data coming in to process, will over head of creating new thread reduce performance a lot than having all the thread running all the time? Should I handle incoming data sequentially and try to avoid blocking during the process?
    TIA

    If you would take the trouble of reading the previous 10 or 20 posts in this forum about threads and/or NIO you would have your answer, or at least most of it.

  • Problems with block diagram selection

    Hello all,
    I experience some problems in LV 8.2 I have not seen before in other LV- Versions. When I use the mouse scroll- wheel to change the displayed portion of the BD and then select some code by drawing a rectangle, the selection frame appears at a different position. But the area I actually want to select appears selected. I use the Auto-tool. I can force this behaviour by doing the following:
    scroll the BD
    take care, not to touch any element on the BD (wires, terminals, SubVIs...)
    draw a selection frame
    This works for scrolling up-down and for scrolling left-right by placing the mouse-cursor at the scroll bars. But it doesn't happen when I scroll by drawing the scroll bar.
    I appended some pictures to show this.
    Has any one experienced this too and is there some fix available?
    Greets, Dave
    Greets, Dave
    Attachments:
    selection 2.png ‏64 KB
    selection 3.png ‏63 KB

    I can't duplicate the problem.
    Usually problems like this are related to the video driver. Sometimes updating, or jusr re-installing the video driver will take care of the issue. It could also be a mouse driver problem. I'd also try upgrading/re-installing the mouse driver.
    Let us know if either of those takes care of the problem.
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.

  • Who can solve my problem? My problem in below.

    Who can solve my problem? My problem in below.

    hi,my problem now is :
    exception
    org.apache.jasper.JasperException
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    java.lang.NullPointerException
         net.sf.hibernate.examples.quickstart.HibernateUtil.currentSession(HibernateUtil.java:24)
         org.apache.jsp.testCat_jsp._jspService(testCat_jsp.java:65)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    package net.sf.hibernate.examples.quickstart;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import net.sf.hibernate.*;
    import net.sf.hibernate.cfg.*;
    public class HibernateUtil {
    private static Log log = LogFactory.getLog(HibernateUtil.class);
    private static SessionFactory sessionFactory ;
    static {
    try {
    // Create the SessionFactory
    sessionFactory = new Configuration().configure().buildSessionFactory();
    catch (Throwable ex) {
    log.error("Initial SessionFactory creation failed.", ex);
    System.out.println(ex.toString());
    public static final ThreadLocal session = new ThreadLocal();
    public static Session currentSession() throws HibernateException {
    Session s = (Session) session.get();
    // Open a new Session, if this Thread has none yet
    if (s == null) {
    s = sessionFactory.openSession();
    session.set(s);
    return s;
    public static void closeSession() throws HibernateException {
    Session s = (Session) session.get();
    session.set(null);
    if (s != null)
    s.close();
    }

  • Exception in thread "JMF thread???

    I try to write a very simple project which just play a local media in an Applet, although this example can be found in a lot of places, I met an Exception which kind of strange, Can anyone met this before? My Code is very simple.
    import java.applet.Applet;
    import java.awt.BorderLayout;
    import java.awt.*;
    import java.io.*;
    import java.net.MalformedURLException;
    import java.net.URL;
    import javax.media.*;
    import javax.swing.*;
    public class test1 extends Applet{
         URL url;
         Player player=null;
         public void init(){
              setLayout( new BorderLayout() );
              try {
                   URL mediaURL = new URL(getDocumentBase(), "A Perfect Indian.mp3");
                   System.out.println(mediaURL);
                   player = Manager.createRealizedPlayer(mediaURL);
              }catch(Exception e){
                   System.out.println("problems here 1");
                   e.printStackTrace();
    Exception in thread "JMF thread: com.sun.media.amovie.AMController@7c6768[ com.sun.media.amovie.AMController@7c6768 ] ( realizeThread)" java.lang.UnsatisfiedLinkError: com.sun.media.amovie.ActiveMovie.openFile(Ljava/lang/String;)Z
         at com.sun.media.amovie.ActiveMovie.openFile(Native Method)
         at com.sun.media.amovie.ActiveMovie.<init>(ActiveMovie.java:47)
         at com.sun.media.amovie.AMController.createActiveMovie(AMController.java:293)
         at com.sun.media.amovie.AMController.doRealize(AMController.java:416)
         at com.sun.media.RealizeWorkThread.process(BasicController.java:1400)
         at com.sun.media.StateTransitionWorkThread.run(BasicController.java:1339)

    An unsatisfied link error occurs when the JVM cannot find a class in a library that it was expecting to be able to find.
    In this instance, it sounds like you (1) didn't include JMF.jar in your applet's classpath, and/or (2) didn't include the MP3 plugin to your applet's classpath...

  • I Ipod class wont play TED and other video podcasts.  The genious bar could not figure out the problem.  This problem is not isolated to a single computer.  Secondly, the convert to ipod version feature in Itunes does not resolve the problem.

    My Ipod classic wont play TED, The Grid, Techzilla and other video podcasts (but not all video podcasts).  The genious bar could not figure out the problem. Instead, the Apple store gave me credit towards a new classic, which produced the same problem.  This problem is not isolated to a single computer.  Secondly, the convert to ipod version feature in Itunes does not resolve the problem.  Lastly, I tried restoring the ipod to no avail.  I've heard this is a video codec problem. 

    See this extensive older thread on the issue.
    https://discussions.apple.com/thread/2813428?start=45&tstart=0
    B-rock

  • Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/

    hi,
    I am getting error message when i run HttpClient in my java class. Will the HttpClient will work in weblogic.
    HttpClient httpclient = new HttpClient();
    I added "commons-httpclient-3.1.jar" in the class path also.
    Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/kernel/KernelLogManager
         at weblogic.logging.commons.LogImpl.<init>(LogImpl.java:14)
         at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:21)
         at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:18)
         at org.apache.commons.httpclient.HttpClient.<clinit>(HttpClient.java:66)
    Thanks
    Manu

    Again you need to make a difference between what runs within the weblogic container to what runs in a vanilla JVM. Understanding this is crucial to your problem.
    1. web service -> client -> another web service
    The webservice will always run within the weblogic container and you should never get the ClassnotFound because weblogic.jar is always available there. Any subsequent clients loaded into the same JVM will presumably be in the same classloader and wont have problems either
    2. client -> web service;
    If you are using a standalone client in a JVM you shouldnt have any dependency on weblogic and commons-httpclient will work just fine as would commons-logging. However if you include some weblogic jars in the classpath, when you launch the client JVM you would need to include the jars mentioned in the other post because they reference other weblogic classes. But this isn't necessary if you just clean up your classpath to only have the jars you need.

  • Photoshop CS2 Upgrade Installation Problems w/ Vista Problems

    I recently purchased a new laptop w/ Windows Vista which I'm trying to install my copy of Photoshop CS2 onto. My Photoshop license is an upgrade license ... originally upgraded from Photoshop v4.0.
    When installing an upgrade copy of PS CS2, it requires proof of your previous version in order to verify you're a legitimate upgrader. This works fine if you're upgrading from a version of Photoshop after 5.x ...you simply insert your CD and the installation continues. The installation process is less straight-forward for users like myself ... installing from an upgraded version prior to 5. I'm required to call Adobe ... and conduct a phone verification procedure where I give them a code displayed on the screen during installation and they give me a response code to type into the installation form.
    I deauthorized my old laptop ... start the installation routine on my new laptop ... call Adobe w/ my verification code ... enter the response code (which is accepted) and complete the installation without any problems. My problem occurs when I go to run the software. The startup screen indicates that the software is still in "Tryout Mode", and the first window I'm presented with is the "Adobe Activation" window requesting my serial number. If I try to enter my CS2 serial number it is rejected with the message:
    "You must enter a valid serial number before activating online or viewing activation options. Please check your serial number and re-enter it, or click the Purchase button to buy a copy of this product"
    The thing is ... this IS a valid serial number. I've confirmed this with Adobe. (It's probably an upgrade serial number, which is why the software is rejecting it). I called Adobe and they're now telling me that I must enter a paid-support agreement in order to receive help installing my software. They claim their software is working correctly, and it must be a problem with my computer.
    Has anybody experienced a problem like this? I refuse to pay more for something that worked fine on XP just to use it on Vista due to bugs in their installation and activation routine.

    function(){return A.apply(null,[this].concat($A(arguments)))}
    mthight wrote:
    Have the bugs of using with Vista been fixed, or still not working? thanks,
    I know this is an old problem, but surely there is an answer to fix the problem by now...
    What problems?  I used Photoshop CS2 with Vista with no problems (I still have it installed on a Vista system if you'd like me to check anything in particular).  CS3 and CS4 worked well as well.  Haven't tried CS5 on Vista as I have moved up to Windows 7, but I suspect it works just fine.
    -Noel

  • I can not eliminate ASK engine from the list. It came back by itself. Please, tel me how I can eliminate this problem. Another problem, this browser is no longer compatible with some institutions. This new version might have some problems.

    '''I can not eliminate ASK engine from the list. It came back by itself. Please, tel me how I can eliminate this problem.
    Another problem, this browser is no longer compatible with some institutions. .'''

    Step by step, how did you arrive at seeing this agreement?

  • "Problem with Trial - problem loading trial period for Adobe Photoshop CS3"

    Hello,
    I installed Photoshop CS3 Trial and whenever I run it and choose to begin my trial period I get the following error message:
    "Problem with Trial - problem loading trial period for Adobe Photoshop CS3".
    I tried uninstalling and reinstalling, and even ran the Adobe CS3Clean Script but nothing seems to help.
    I should note I never installed any earlier version of Photoshop on my system (I use a fresh copy of Windows XP with only a few programs installed).
    Any suggestions will be appreciated.
    Thanks,
    David

    i had the trial of photoshop on and the trial has run out my friend has given me a disk with adobe photoshop on and i cant do it beacause of the regestry code the photoshop puts in after the trial has ended to tell my pc that i cant have photoshop on my computer again :(:( now i have herd that you can remove the codes but it is quite hard well iam willing for this challenge and if anyone could help me i would reall welcome your help or if anybody has got the link to a tutorial to tell me hoe to do it i would aprecitae that to thank you all very much and post bak soon please

Maybe you are looking for