Urgent!!!!!!!HANDLER THREAD PROBLEM

file name GetName.html
<html>
<body>
<FORM METHOD = POST ACTION = "SaveName.jsp">
what is your name?
<INPUT TYPE = TEXT NAME=username SIZE= 20>
<p><INPUT TYPE= SUBMIT>
</FORM>
</BODY>
</HTML>
file name SaveName.jsp
<%
String name = request.getParameter( "username" );
session.setAttribute( "theName", name );
%>
<HTML>
<BODY>
Continue
</BODY>
</HTML>
file name NextPage.jsp
<html>
<body>
Hello, <%=session.getAttribute("theName") %>
</body>
</html>
when I try to execute , SaveName.jsp is generating the following error message. what is the problem? I am using jswdk. please help. I have included tools.jar in classpath. what could be the problem?
Unhandled error! You might want to consider having an error page to report such
errors more gracefully
com.sun.jsp.JspException: Compilation failed:Note: sun.tools.javac.Main has been
deprecated.
work\%3A8080%2Fexamples\SaveName_jsp_1.java:71: Method setAttribute(java.lang.St
ring, java.lang.String) not found in interface javax.servlet.http.HttpSession.
session.setAttribute( "theName", name );
^
1 error, 1 warning
at com.sun.jsp.compiler.Main.compile(Main.java:347)
at com.sun.jsp.runtime.JspLoader.loadJSP(JspLoader.java:135)
at com.sun.jsp.runtime.JspServlet$JspServletWrapper.loadIfNecessary(JspS
ervlet.java:77)
at com.sun.jsp.runtime.JspServlet$JspServletWrapper.service(JspServlet.j
ava:87)
at com.sun.jsp.runtime.JspServlet.serviceJspFile(JspServlet.java:218)
at com.sun.jsp.runtime.JspServlet.service(JspServlet.java:294)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at com.sun.web.core.ServletWrapper.handleRequest(ServletWrapper.java:155
at com.sun.web.core.Context.handleRequest(Context.java:414)
at com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:139)
HANDLER THREAD PROBLEM: java.net.SocketException: Socket is closed
java.net.SocketException: Socket is closed
at java.net.Socket.getInputStream(Socket.java:643)
at com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:161)

Are you using JSWDK 1.0.1? If you are, then the implementation uses the Servlet Spec. 2.1. The set/getAttribute methods were added in 2.2.
Try using the now-deprecated method putValue like this in SaveName.jsp.
<%
String name = request.getParameter( "username" );
session.putValue( "theName", name );
%>

Similar Messages

  • HANDLER THREAD PROBLEM?

    I'm trying to use the method Response.sendRedirect to forward users to another website. The actual case is irrelevant so I've extracted the important part into a simple servlet example:
    import javax.servlet.http.*;
    import java.io.*;
    public class ReDirect extends HttpServlet
       public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException
          if(req.getQueryString()!=null)
             res.setContentType("text/html");
             res.getWriter().println("Your querystring: <b>"+req.getQueryString());
          else
             res.sendRedirect("http://java.sun.com");
    }The funny thing is that the servlet works FINE, but that darn thing is generating an IOException (showing in the DOS prompt of the webserver) everytime the sendRedirect method is called! Why?
    ReDirect: init
    HANDLER THREAD PROBLEM: java.io.IOException: Socket Closed
    java.io.IOException: Socket Closed
         at java.net.PlainSocketImpl.getInputStream(PlainSocketImpl.java:432)
         at java.net.Socket$1.run(Socket.java:335)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.Socket.getInputStream(Socket.java:332)
         at com.sun.web.server.ConnectionHandler.run(ConnectionHandler.java:161)I have tried everything... I've also searched the forum for similar problems, but it seems that noone have a logic explanation for this. Is this a bug in the servlet engine or is it something I'm doing wrong or have forgotten?
    I'm using jswdk 1.0.1 and jdk1.3.1 on windows 2000, running the webserver that comes with jswdk.
    Please, someone, explain this to me! This problem is torturing me day and night!!
    /Stefan Westling

    Go get tomcat ...I used to get this error lot's when I used the jswdk. There are just some things it doesn't like ...yet when structured in certain way's ...it would work. I never did track down any consistent explanation. I just moved on to tomcat. The jswdk is really cheesy ...it can't do post ...or sessions ...or any 2.0 functionality ... or ... or ... Go get tomcat.

  • Sun Java System Web Server 6.1 SP3 service-j2ee threads problem

    Hi,
    Sorry my english.
    I'm an intermediate Java programmer and a newbie in
    the Sun's web servers world.
    I'm doing an evaluation of an web applicaction
    written in Java Servlets that is
    supposed to have a leaking threads problem. We use
    SunOS 5.9 (... sun4u sparc SUNW,UltraAX-i2) and
    JVM 1.5 Update 4 (the problem is presented too
    in SunOS 5.8 and JVM 1.4.2_04).
    We have seen, thanks to 'prstat' (PROCESS/NLWP) a
    increasing thread's growing in one of the process
    that correspond to our web server instance (I'm sure I'm
    looking the right process). I have checkout the source
    code and it seems like the app doesn't have threads
    problems. I have used the Netbeans Profiler and I see a
    high number of threads called service-j2ee-x that grows
    in congestion moments and never disappear.
    Anybody could help me with suggestions?
    Thank you very much.

    Elvin,
    Thankyou, yes I am unfamiliar with debugging Java apps. I got the web server Java stack trace and I have passed this on to the developer.
    The web server finally closes the socket connection after the total connections queued exceeds 4096.
    There are several hundred entries like this... waiting for monitor entry.. could be a deadlock somewhere?
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: "service-j2ee-506" prio=5 tid=0x04b62a08 nid=0x17a waiting for monitor entry [dd74e000..dd74f770]
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at com.verity.search.util.JSDispenser.getConnResource(Unknown Source)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: - waiting to lock <0xe979b2b0> (a com.verity.search.util.JSDispenser)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at com.verity.search.DocRead.getDoc(Unknown Source)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at com.verity.search.DocRead.getDoc(Unknown Source)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at com.verity.search.DocRead.docViewIntern(Unknown Source)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at com.verity.search.DocRead.docView(Unknown Source)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at au.com.relevance.viewDoc.PdfXmlServlet.performRequest(PdfXmlServlet.java:120)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at au.com.relevance.viewDoc.PdfXmlServlet.doGet(PdfXmlServlet.java:141)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at javax.servlet.http.HttpServlet.service(HttpServlet.java:787)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at com.iplanet.ias.web.WebContainer.service(WebContainer.java:580)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at com.iplanet.ias.web.WebContainer.service(WebContainer.java:580)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: "StandardManager[highlight]" daemon prio=5 tid=0x000f3530 nid=0x1e waiting on condition [e15ff000..e15ffc28]
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.Thread.sleep(Native Method)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.session.StandardManager.threadSleep(StandardManager.java:800)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.session.StandardManager.run(StandardManager.java:859)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.Thread.run(Thread.java:534)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: "WebappLoader[highlight]" daemon prio=5 tid=0x000f3328 nid=0x1d waiting on condition [e16ff000..e16ffc28]
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.Thread.sleep(Native Method)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.loader.WebappLoader.threadSleep(WebappLoader.java:1214)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.loader.WebappLoader.run(WebappLoader.java:1341)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.Thread.run(Thread.java:534)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: "StandardManager[]" daemon prio=5 tid=0x000f2b08 nid=0x1c waiting on condition [e1b7f000..e1b7fc28]
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.Thread.sleep(Native Method)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.session.StandardManager.threadSleep(StandardManager.java:800)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.session.StandardManager.run(StandardManager.java:859)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.Thread.run(Thread.java:534)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: "WebappLoader[]" daemon prio=5 tid=0x000f2900 nid=0x1b waiting on condition [e1c7f000..e1c7fc28]
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.Thread.sleep(Native Method)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.loader.WebappLoader.threadSleep(WebappLoader.java:1214)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.loader.WebappLoader.run(WebappLoader.java:1341)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.Thread.run(Thread.java:534)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: "StandardManager[sitesearch]" daemon prio=5 tid=0x000f1cd0 nid=0x1a waiting on condition [e23ff000..e23ffc28]
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.Thread.sleep(Native Method)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.session.StandardManager.threadSleep(StandardManager.java:800)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.session.StandardManager.run(StandardManager.java:859)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.Thread.run(Thread.java:534)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: "WebappLoader[sitesearch]" daemon prio=5 tid=0x000f1ac8 nid=0x19 waiting on condition [e24ff000..e24ffc28]
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.Thread.sleep(Native Method)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.loader.WebappLoader.threadSleep(WebappLoader.java:1214)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.loader.WebappLoader.run(WebappLoader.java:1341)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.Thread.run(Thread.java:534)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: "StandardManager[search]" daemon prio=5 tid=0x000f0a88 nid=0x18 waiting on condition [e317f000..e317fc28]
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.Thread.sleep(Native Method)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.session.StandardManager.threadSleep(StandardManager.java:800)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at org.apache.catalina.session.StandardManager.run(StandardManager.java:859)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.Thread.run(Thread.java:534)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: "Signal Dispatcher" daemon prio=10 tid=0x000ef840 nid=0x12 waiting on condition [0..0]
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: "Finalizer" daemon prio=8 tid=0x000ef638 nid=0x10 in Object.wait() [fa27f000..fa27fc28]
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.Object.wait(Native Method)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: - waiting on <0xe917fb10> (a java.lang.ref.ReferenceQueue$Lock)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: - locked <0xe917fb10> (a java.lang.ref.ReferenceQueue$Lock)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: "Reference Handler" daemon prio=10 tid=0x000ef430 nid=0xf in Object.wait() [fa37f000..fa37fc28]
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.Object.wait(Native Method)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: - waiting on <0xe917fb78> (a java.lang.ref.Reference$Lock)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.Object.wait(Object.java:429)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:115)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: - locked <0xe917fb78> (a java.lang.ref.Reference$Lock)
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: "main" prio=5 tid=0x000ee3f0 nid=0x1 runnable [0..ffbff200]
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: "VM Thread" prio=5 tid=0x004ee328 nid=0xe runnable
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: "VM Periodic Task Thread" prio=10 tid=0x004ee5d0 nid=0x16 waiting on condition
    [15/May/2006:22:01:51] warning ( 3196): CORE3283: stderr: "Suspend Checker Thread" prio=10 tid=0x004ee548 nid=0x11 runnable
    [15/May/2006:22:15:10] failure ( 3196): HTTP3287: connection limit (4096) exceeded, closing socket

  • JNI & thread problem

    Folks,
    I am using JNI to access WIA (Windows Image Acquisition) functionality under MS Windows XP. WIA consists of a bunch of COM interfaces. I have several native functions in a single dll, with a limited number of static variables stored in the dll between calls. This all works fine as long as long as the calls occur from the same java thread, but not if a new thread is created for some of the calls. I.e., this works:
    final WIACtrl ctrler=new WIACtrl();
    ctrler.initializeWIA();
    ctrler.transferJPGNative("0001\\Root\\IMG_0087","c:\\test.jpg");
    but this does not:
    final WIACtrl ctrler=new WIACtrl();
    ctrler.initializeWIA();
    (new Thread() {
    public void run() {               
    ctrler.transferJPGNative("0001\\Root\\IMG_0087","c:\\test.jpg");
    }).start();
    Here, initializeWIA() and transferJPGNative() are the native methods. What happens in the second case is that transferJPGNative fails in one of the COM methods (not the first COM method it calls). The COM method returns an HRESULT indicating an error (509) which I can't find using any of the usual MS error look-up mechanisms. (Admittedly I am not the world's greatest Windows programmer...)
    Anyway, any suggestions would be much appreciated. I have found some issues regarding JNI and threads in this forum's archives, but none of them seem to apply to quite this situation.

    As a guess this is just a windows threading problem.
    And with COM you have to do things differently (I believe) if there is more than one thread. You might not even be allowed to do it with for that particular API.
    It could also be that you are initializing things more than once. Or you need to initialize twice (two handles.)
    At any rate you could always fix it by making the java code only allow calls for a single thread.

  • Multiple event-handling threads?

    I am writing a Java program that will launch other Java programs within the same JVM. This feature is for an RAD IDE that currently uses Runtime.exec.
    The main problem is that the launcher is an IDE that will try to launch Swing applications within the same JVM. If a badly-written program traps the event-handling thread, it will bring the whole IDE down. The IDE's "Kill" button wont even work.
    Is there any way to tell the JVM to use different event-handling threads for my application? Alternatively, does anybody know of any obscure functions I could use to maybe cause the event-handling thread to delegate processing to another one of my own threads? Ugly hacks are welcome.

    After I first posted this question, I've taken a look at the java.awt.EventQueue class. The API provides an easy way to use your own EventQueue that could possibly dispatch events with multiple threads. If you make sure that you only use one thread at a time for each virtual JVM, I don't think that there will be any thread issues (unless there are any assumptions in AWT/Swing code about there only being one thread).
    About the load time being 0.5 seconds. I'm sure it'll improve, but a failed load only loads and links a minimum number of classes. I wrote a program that runs the java compiler from com.sun.tools.javac.Main and it looks like the load time is about 1.75 seconds. Since the compile time itself is usually under a second for around 2000 lines of code, this kind of makes a difference (500MHz P3, by the way). This load time will probably be even greater for Swing applications.
    When you're lauching a big program it may not matter much but the load time really kills Java's ability to create a quick command-line tool (not that it's best-suited for such a tool anyway, but it would be nice to have that barrier removed).
    The biggest problem with creating a lightweight JVM right now is probably the stupid File class. Even if you change "user.dir" in the system properties, many File methods still resolve relative to the original "user.dir". Though many other problems exist, this is the one that really kills it because of the pervasiveness of the File class.

  • Cant syncronize! Threads problem

    Hello everybody,
    recently i posted a question(im new to threads) and it was asked immediately but now i have another
    type of problem.
    Please read here the initial post and the answer and please give me any ideas..
    Initial Post
    Hi everybody,i have this thread problem(i'm new to java and h
    ave no idea what exactly to do).
    Well,in my applet i have this action performed method
    that i imagine is in the event dispatch thread.
    This method calls as u see, two other methods of a class named CPU(.
    Note that fetch and execute are observed classes and my applet class
    is the observer.
    The problem is that during the execution of fetch() and execute(),
    inside these methods change some things and so they call notifyObservers(Object arg)
    passing to the applet the argument and so the applet updates some text components.
    But as you can immagine there is no time for the gui to update himself so i see nothing.
    So, my question is which of the methods need to be in a separate thread so to ensure
    visible results(component updating)?
    Perhaps,the update method needs to be invokedLater with SwingUtilities?
    Please give me an example code if possible.
    Here is the actionPerformed code(from the applet class) and the fetch method:
        void executeProgramButton_actionPerformed(ActionEvent e) {      
    int numInstr = this.machine.ram.segmentSize;       
    for (int i = 0; i < numInstr; i = i + 4) {           
    machine.cpu.fetch();           
    machine.cpu.execute();       
    /*The following method is in the CPU class
    fetch method:here the observedPC is the observable value
    that notifies the observer(the main applet)
    that does: pcTextField.setText(arg.toString());*/   
    public void fetchInstructionProgram() {       
    observedPC = Integer.toString(pc);       
    setChanged();       
    notifyObservers(observedPC);       
    instructions++;       
    instruction=readOperation(cache.instructionfetch,pc);       
    pc = pc + 4;    }
    Answer to initial post
    Author: stevejluke
    One way could be to put the content of the action performed method into a new thread, then use invokeLater in your Observers that cause GUI updates:
        void executeProgramButton_actionPerformed(ActionEvent e) {     
    new Thread()       {      
    public void run()        {         
    int numInstr = this.machine.ram.segmentSize;         
    for (int i = 0; i < numInstr; i = i + 4)           {           
    machine.cpu.fetch();           
    machine.cpu.execute();         
    }.start();    }
    // In your Observer    public void update(Observable o, Object arg)    {     
    SwingUtilities.invokeLater(new Runnable() {      
    public void run()        { 
    /* your GUI afecting code
    });[i]
    Or something like that.
    You might need to watch for synchronizing things
    He was right...GUI is responsive but the results...
    Well,let me describe the new problem.
    Here you cant see the method execute().
    The problem is a synchronization problem.
    Actually,what the two methods do is:fetch() updates the value of a long called instruction and execute() takes this value and do some things.Note also that the time the execute method needs to finish is not
    always the same.By that, i mean that it depends on the value of the instruction updated by fetch().
    By putting some System.outs before and after updating i realized that there are delays or sometimes
    i noticed that fetch() executes 2 times before execute() takes control.
    So,i created some synchronized private methods set and get to control access to these resources.
    Better but still not correct...
    What should i look?Where stays the answer?
    How to synchronize these two methods on these resources?
    Thank you in advance,
    Chris

    I think that your fetch and execute has a "Producer-Consumer Relationship"
    in such cases you can make the producer place the produced value in to a queue and consumer take the vlues from the queue
    In the producer thread it sleeps for a while and try again if the Queue is full
    In the Consumer thread it sleeps for a while if the Queue is empty and then try again
    Or you can do as follows
    In the Producer thread it waite() if the Queue is full
    In the Consumer thread it waite() if the queue is empty
    When ever Producer put a value in to the Queue it calls the notify on Consumer and when ever Consumer takes a value from Queue it calls the notify() on Producer
    you can even use notify all
    I think thiere is no built in Queue class in java so you will have to write one here is a example
    public class MyLongQueue{
                long data[];
                int head, tail;
                int size;
               public MyLongQueue(int size){
                    data = new long[size];
                    head = -1;
                    tail = -1;
                    this.size = 0;
                public synchronized boolean isFull(){
                    return (size==data.length);
                public synchronized boolean isEmpty(){
                    return (size==0);
                public synchronized boolean  insert(long l){
                    if (size==data.length) return false; //Queue is full cant add more data
                    tail = (tail + 1) % data.length;
                    data[tail] = l;
                     size++;
                    return true;
               public synchronized long remove(){
                   if (size==0) throw new ArrayIndexOutOfBoundsException();
                   size--;
                   head = (head + 1) % data.length;
                   return data[head];

  • Thread problem in swings

    I have made an application in swings i have stored the class files in a system and call that class files by a batfile shortcut in two diff. pcs .and i am tring to get an value of a Jtextarea in an event When I tried to run this application at the same time from 2 diff PCS,with diff string input in text area It is giving me the same vlaue.
    Tell me Y it is so.and how can i rectify it
    javauser

    Very strange... what makes you think that this is a threading problem?

  • Exception in handler thread. in BI Presentation Services

    Hi
    We are revicing following error in OBIEE 11g presentation services
    Dose anyone know the reason?
    +Exception in handler thread. An error occurred during execution of "send". Broken pipe [Socket:82]^M+
    Error Codes: ETI2U8FA^M
    Location: saw.rpc.variablemos.finalize, saw.rpc.server.responder, saw.rpc.server, saw.rpc.server.handleConnection, saw.rpc.server.dispatch, saw.threadpool, saw.threadpool, saw.threads^M
    +[[+
    File:socketrpcserver.cpp
    Line:565
    Location:
    saw.rpc.server.handleConnection
    saw.rpc.server.dispatch
    saw.threadpool

    Hi ,
    By any chance have you changed anything in socketrpcserver.cpp ??
    looks like the file has changed or not copied propelry.
    Open the socketrpcserver.cpp in vi editor and check if it contains any control M charatcers (^M).
    Or
    It can be because of the JavaHost process not running. Check instanceconfig.xml (check the port number)
    If you have changed the JavaHost Port Number (default is 9810), you need to update it in instanceconfig.xml.
    <JavaHostProxy>
    <Hosts><Host address="myhost.domain.com" port="newport>" /></Hosts>
    </JavaHostProxy>

  • Thread problems with Samsung D500? Http or https troubles?

    Hi!
    I've got some troubles with my application installed onto my D500, and I suspect that's maybe thread problem.
    Does anyone know something about thread problems for this phone?
    I want to know, is there any trouble for connecting application by using http or https?
    I've found one problem for E720 - it escapes "backslash" character when it's used as http parameter.
    It makes parsing troubles...
    Did anyone have some similer troubles, and how have you solved this problem?
    Thanks in advance,
    Alex

    When I'm trying to connect to the net by using my application, I get two errors: "TCP open" and "interruptedIOException", and so I suspect that's some kind of thread problems.
    On the other phones (Nokia, Sony Ericsson) this application works with no problems...

  • My iphone is switched off as low batery and still viberates. how should i handle that problem?my iphone is switched off as low batery and still viberates. how should i handle that problem?

    my Iphoe is switched off and still viberates. how should i handle that problem?

    Try to set it up as new device and don't use the backup afterwards:
    How to back up your data and set up as a new device

  • How to handle thread

    i am using two methods. one is send method to send message and another one is receive method to receive message.if i am typeing message that time i want check if any message is receive or not.If any receive i want to display that receive.

    Double-post: http://forum.java.sun.com/thread.jspa?threadID=761176
    You really don't seem to know how to handle threads...

  • Urgent : UI refresh problem on dual processor or hyper threaded machine

    Hello,
    I am developing an applet that displays a set of tabs to the user. Each tab contains JLists.
    When user selects from any of the JList(s), all lists are updated to reflect what is still available for selection. Number of elements in the list can be as large as few hundred thousands. This all works fine on single processor machine.
    However, when running same on dual processor or Intel hyperthreaded processor, lists are not updated correctly. What I meant is that, for example, if a list originally has 100 thousands elements in it, then when I select an element from it, list is updated with available elements.Assume there are only 2 thousand elements available after above selection.Everything is fine so far, but when I de-select my selection, list is suppose to be updated again with original 100 thousands elements displayed again. The real problem is list indeed gets updated properly but few elements from list are not visible on the screen. However, If I minimize the browser(as it is an applet) and restore it again, all elemnets within the list are displayed correctly. Any help will be highly appreciated.

    When your JLIst refresh occurs, the items are loaded into the JList from some other Object right? Nt knowing more about your code, I can't say exactly what that would be.Yes, you are right. Let me explain in breif about the architecture of the code.
    I have a class,say CatPanel, that extends from JPanel and has BorderLayout with JList (wrapped in JScrollPane) in the center.
    The main GUI class controls all such CatPanels.So, when the list is to be updated, GUI class invokes a method from CatPanel with Vector of elements to be inserted as an argument. Elements are inserted using setListData method of the JList.
    If I'm right, the this might explain the behavior you are seeing. In a single processor environment, the data >is not cahced and therefore everything is fine. When you go to the dual-processor machine, the threads >have their own caches and are not always in sync. When you mimize the window and restoer it, this could >trigger a resync of the cache.Is there a way to trigger such synchronization?
    One thing I'm not sure about is, when you return to the 'main' list, do you still see the selected sublist or >the main list with some elements missing? When a list is updated as a result of de-selection, few elements from start of the list are not visible.
    I can see all other elements by using ScrollBar. So, if there are some selections that belong to the begining portion of the list, then selected sublist is not visible.
    Let me explain with following example. Assume that with current selection, I have 100 elements in the list and all of them are visible on the screen. Now as a result of de-selection, suppose now the list should contain 200 elements rather than 100 elements. So, what happens in this case is that if first 50 elements are not visible in the list then I can see blank space corresponding to first 50 elements at the start of the list followed by remaining elements. I tried overloading paint method of an element that is actually inserted into the list, but still the result is same.

  • Multiple Threads Problem

    Hi,
    I am new to Java Threading and the current program that I am working is having problems. The program basically paints lines and dots or onto a JPanel which displays an image. There exists a thread here to suspend and resume the drawing at the user's disposal. This part works flawlessly.
    Now since the images are quite large I have attempted to add a JWindow to the JFrame to indiate that the image is loading. And here lies my problem, the JWindow which also contains a paint method does not display anything until after the image is fully loaded onto the JPanel.
    Can someone please tell me what I am doing wrong and how to implement this?
    Thanks, James
    Here is how my program is structured:
    public class Proj extends JFrame
    public Proj()
    Display disp = new Display();
    Thread thr1 = new Thread(disp);
    thr1.start();
    Container con = getContentPane();
    con.add(vsr);
    setSize(500,500);
    show();
    public static void main(String [] args)
    {  new Proj();
    class Display extends JPanel implements Runnable
    public Display()
    Loading ld = new Loading();
    Thread thr2 = new Thread(ld);
    ld.start();
    // gets data and image files
    ld.interrupt();
    public void paintComponent(Graphics g)
    // draws image, lines, circles etc.
    public void run()
    // involved with data to draw next image, lines etc.
    class Loading extends JWindow implements Runnable
    public void paint(Graphics g)
    // displays loading animation
    public void run()
    // animation code

    Since Swing is single-threaded, any painting activity after a component is realized/visible should be handled on the EDT (Event Dispatch Thread). The loading of data/files can be done on worker different thread. On the EDT you should fetch the status and paint your progress bar. If you paint the progress bar on the worker thread it would not work out the way you want. Try to also investigate into SwingUtilities.invokeLater method which allows us to put a code to be executed on the EDT.

  • Handling Threads and Memory

    I'm sorry if this is a cross post to my StringBuffer problem. I have run a test that instantiates the object in question and the memory gets collected so I don't think it's that. My question is on how memory pertaining to Threads is handled.
    In my application I have a Thread array that launches X number of Threads. Currently 5. When an object wants a job run, the static Thread pool looks at the current thread and sees if it is still working. If it is, we sleep until it is available. Then I give it another job to do, start it, and move to the next thread.
    Question 1 -
    In a Thread [] is it better to replace the Thread at position x as in
    threads[a] = new Thread();
    threads[a].start();
    or is it better to change some parameter in the thread and then call
    start() again?
    Question 2 -
    I am currently using the second method. In my Thread object I have a MessageObject which contains a StringBuffer, which is eating memory. These MessageObject's are increasing. Some are being collected but many are staying live in the system and causing a memory error. When I do the following....
    MyThread.MessageObject = new MessageObject()
    That should make the original object available for cleanup right?
    Should I call finalize on the MessageObject before replacing it?
    Thanks you for any insights.

    If you want to use thread pools, and you can use JDK 5.0 (formerly known as J2SDK 1.5, codename Tiger), try using the java.util.concurrent package instead of writing your own thread pool (it's really difficult to make a thread pool right).
    If you can't use JDK 5.0, you can try the original util.concurrent package ( http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html ) from Doug Lea. It's used in the JBoss Application Server, so it's tested and reliable.
    If you need to use an object pool, try using the Commons Pool Component from Jakarta Apache: http://jakarta.apache.org/commons/pool/

  • App running 3000 threads - Problems

    Hello everyone,
    I am writting an app that created 3000 thread, this app polls information from different sources and each thread is configured to execute a specific job.
    The app seems to create the 3000 threads without problems, and it seems to execute well for a random period of time, but afterwards the threads stops working and I don't get any exception message.
    I'm currently working on creating some logs, to gather more information about the problem, but I sincerly think that the threads are stopping in which case the logs will not help much.
    Is there any conciderations when working wiht a large amount of threads. Is there any link to documentation related to this issue ?
    Thanks very much for your help and time.
    Regands,
    Fabian.

    If the mapping between Java threads and operating-system threads is one to one (as done in several JVM implementations, like Sun's JVMs in Windows and Solaris), you can expect problems if your operating system can't handle so many threads in a single process.
    If you want to use lots and lots of threads only for breaking a single computing problem, for instance, you can try the FJTask (from the util.concurrent library from Doug Lea - http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html).
    You can use some kind of "thread pooling" (use the util.concurrent library from Doug Lea, see link above) if your problem can be handled with "thread pools".
    Some problems can be handled with the java.nio package if you want to use Asynchronous I/O - beware, it is not easy to transform a program using Synchronous I/O to a program using Asynchronous I/O.

Maybe you are looking for

  • Pass hidden values to same page by clicking on href

    I have A.jsp page which has some dynamic hidden fields.The respective code is given below: <script language="javascript"> function submitForm() {document.main.action="main.jsp"; document.main.submit(); } </script> <form name="main"> HOME <input type=

  • RH 10: How do I get Heading 1 to appear in printed Word TOC

    Hi, I can't get any Heading 1s to appear in printed Word TOC. Using Books and Topics (with titles as Heading 1 as a test). All other headings appear fine in the Word TOC. RH TOC example Functionality (Book)      Function 1 (Topic) - has Heading 1 tit

  • Multiple CollectionNodes with one SharedID in one app....

    I'm having trouble getting multiple CollectionNodes to use the same sharedID but different Nodes. It looks like the first CollectionNode to try and create a node on a sharedID, succeeds and the rest fail. The documentation for SharedObject refers to

  • HT1355 how to remove data permanently from iphone?

    How to remove photos from iphone permenant and to be sure that no one can restore them again.

  • Any Expert Knows this Problem????

    Hi All, I have Done HTTP--RFC Scenario and i got the Bellow Error in Receiver RFC CC Receiver channel 'CC_RFC_Receiver_IB' for party '', service 'Sub_ssd_subdev' Error can not instantiate RfcPool caused by: com.sap.aii.af.rfc.RfcAdapterException: err