Help with Threads for a webserver

That is the main class of my webserver. The problem is that after executing one petition the server closes with exit status 1. Normally that should never happens as it does not happen at the single-threaded server. Any suggestions ??
Also do i have to impement monitors, meaning syncronized functions to monitor buffers and some static variables ?
This is my first program impementing threads so really i do not experience over it
package jhttp_server;
import java.io.*;
import java.net.*;
import java.lang.*;
* <p>Title: JHTTP_server</p>
* <p>Description: A simple HTTP server implemented with Java</p>
* <p>Copyright: Copyright (c) 2004 - Lisenced under GPL</p>
* <p>Company: Universidad Rey Juan Carlos</p>
* @author Panayiotis Papadopoulos -> [email protected]
* @version 0.1
public class jserver {
static ServerSocket serverSocket = null;
static PrintWriter out;
static BufferedReader in;
static Socket client = null;
static short i=0;
static int port;
static boolean newSock=true;
public static void main(String[] args) throws IOException {
port = Integer.valueOf(args[0]).intValue();
try {
     serverSocket = new ServerSocket(port);
catch (IOException e) {
     System.out.println("Must Enter a port number");
System.out.println("|------------------------------------------------------------------------|");
System.out.println("|JHTTP Server initialized and accepting connections on port:" +
serverSocket.getLocalPort()+"\t |");
System.out.println("|------------------------------------------------------------------------|");
while(true){
while (i < 5) {
i++;
try {
//Creating if needed a new socket where the clients listens
if (newSock) {
client = serverSocket.accept();
in = new BufferedReader(new InputStreamReader(client.getInputStream()));
out = new PrintWriter(client.getOutputStream());
System.out.println("LOG: Client is listening on port: "+client.getPort());
//Here the server creates a new thread for the petition
petition newPet = new petition();
newPet.T.start();
} // try- create input and output buffers
catch (UnknownHostException e) {
System.err.println("JHTTP Server could establish a connection. Exiting...");
catch (IOException e) {
System.err.println("Could not get I/O for the connection to client.");
} //try - create client sockets, wait and attend connection
} //while 5 petitions
System.out.println("Session Closed. 5 continious petitions served.");
out.close();
in.close();
client.close();
newSock = true;
System.gc();
i=0;
} // while - forever
}// -------------------main-------------------
}// jserver - main class of JHTTP server project
class petition implements Runnable {
Thread T;
petition () {
T = new Thread(this);
T.start();
public void run() {
try {
//Analyse petition
Petition_Analysis.Analyse_Petition(jserver.in);
//Then Attend it
if (Petition_Analysis.pt.Version.equals("v10"))
Http_10.Attend_Petition(Petition_Analysis.pt, jserver.out, extra.detectConnectionAlive());
else if (Petition_Analysis.pt.Version.equals("v11"))
Http_11.Attend_Petition(Petition_Analysis.pt, jserver.out, extra.detectClose());
else {
jserver.out.print("HTTP/1.0 400 Bad Request\r\n\r\n");
jserver.out.close();
jserver.in.close();
jserver.client.close();
jserver.newSock = true;
//The following function immediately prints the contents of the PrinterBuffer
jserver.out.flush();
System.gc();
catch (MalformedURLException murle) {
jserver.out.print("HTTP/1.0 400 Bad Request\r\n\r\n");
try { jserver.client.close(); }
catch(IOException ioe) { System.out.println(ioe); }
jserver.newSock = true;
catch (NullPointerException npe) {}
//try - analyse petition & attend it
catch (IOException ioe){
System.out.println(ioe);
} // -- run()
} // --class: thread

Use code tags when posting code.
Given that the code you presented does not call System.exit() I am not sure how it could be exiting with a value of 1.
When you accept a connection from a client the code should do nothing but pass the client socket off to a thread and then start that thread. It should not extract the streams - do that in the thread.
The in/out streams of the client socket should be wholly contained within the thread/Runnable. They do not belong to the class that holds the SockerServer.
Your catch blocks need to be reworked. The first one completely ignores the exception and prints out that a port number is needed. You should be printing the exception message at a minimum and right now you should be be doing a printStackTrace() as well. Additionally you are ignoring a null pointer exception and that is wrong.

Similar Messages

  • Help with updates for CS6

    I need help installing latest updates for CS6.  I have Win 7 and have tried updating from the Help - Updates menu.  The error is:  U43M1D207.

    Thanks for your response.  I am in the United States in So. Arizona.
    Date: Fri, 5 Oct 2012 12:21:45 -0600
    From: [email protected]
    To: [email protected]
    Subject: Help with updates for CS6
    Re: Help with updates for CS6 created by Jeff A Wright in Downloading, Installing, Setting Up - View the full discussion
    Crunkle1 you are welcome to work directly with our support team for guided assistance.  If you go to http://www.adobe.com/ and select Help and Contact Us you should be given the option to contact our support team via telephone.  Which country/region are you in?
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/4752605#4752605
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4752605#4752605
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4752605#4752605. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Downloading, Installing, Setting Up by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Help with Threads

    I need help with threads. How can I break this code into teo threads without chaning the data objects at all? Producer will produce string line by line and consumer will take the line and search for the word. Help me please.
    Thank you
    public class WordFinder
    * Main program opens the file given by the user as an argument and
    * searches for the word given by the user. If the word is found,
    * the line number on which the word occurs is displayed.
    * @param args[0] Word to search for
    * @param args[1] Name of file to search
    public static void main(String[] args) throws IOException
    // To keep track of how long the program runs we'll set the startTime
    // variable to the current time in milliseconds and use that at
    // the end of the program to find out how long we ran.
    long startTime = System.currentTimeMillis();
    String wordToFind;
    String currentLine;
    int lineCount = 0; // Keep track of line numbers
    BufferedReader inputFile = null; // Needed to get compiler to quit
    // complaining about uninitialized
    // variables.
    // Make sure we have 2 arguments passed to us
    if (args.length < 2)
    // Nope. Show user how to run and then exit with an error (1)
    System.out.println("usage: java WordFinder <word> <file pathname>");
    System.exit(1);
    // So far, so good. Now try to open the file the user gave us as
    // a parameter. We'll use a BufferedReader object to read the file
    // so we can read one line at a time from the input. If opening the
    // file fails, print an error message and exit with an error (1).
    try
    inputFile = new BufferedReader(new FileReader(args[1]));
    catch (FileNotFoundException e)
    System.out.println(args[1] + ": File not found or is not readable");
    System.exit(1);
    // Set the wordToFind variable to refer to args[0]. We don't
    // really need to do this, but it makes our code more readable
    wordToFind = args[0];
    // We're going to read the file one line at a time. For each
    // line, we'll create a StringTokenizer object to break the line
    // into distinct words, checking each word to see if it's the same
    // as the given search word.
    // Read first line from the file
    currentLine = inputFile.readLine();
    while (currentLine != null) // Repeat until we reach EOF
    // Have a valid input line, increment the counter
    lineCount++;
    // Create a StringTokenizer object over the current line
    StringTokenizer tokens = new StringTokenizer(currentLine);
    // Check each word in the string by accessing each token
    while (tokens.hasMoreTokens())
    // See if the next word is the one we're looking for and
    // advance the token iterator to the next token
    if (wordToFind.equals(tokens.nextToken()))
    // Yes, display the current line number
    System.out.println(wordToFind + " found on line " + lineCount);
    // Read next line from the file
    currentLine = inputFile.readLine();
    } // while
    // Done with the input file
    inputFile.close();
    // Display the running time of this program in milliseconds by
    // subtracting the start time from the current time
    System.out.println((System.currentTimeMillis() - startTime) + " milliseconds");
    } // main
    } // WordFinder

    You may create Queue object. (I guess that you're already know QUEUE)
    Then ... use producer thread to load input file into queue. (Enqueue)
    Consumer ... dequeue
    Queue can be empty because of
    - Input file was read to EOF and Consumer had produced all queue.
    or
    - Cunsumer works too fast... So the queue is empty.
    So, you may have to use ... wait() in Consumer in case of the queue is empty.
    And use notify() in Producer to wake up consumer ...
    Is this right ?

  • Help with Thread dump analisys

    We have problems with our application which runs on bea8.1 sp1.
    Problem is that bea runs out from Threads (StuckThreads).
    thread dums look same for all threads but i can's see what is wrong.
    Here are dumps from first and last threads :
    "ExecuteThread: '1' for queue: 'weblogic.kernel.Default'" daemon prio=5 tid=0x7f3628
    nid=0xd runnable [a6280000..a6281994
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
    - locked <c3197aa0> (a java.io.BufferedInputStream)
    at java.io.DataInputStream.readByte(DataInputStream.java:276)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:189)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
    at com.hutchison3g.core.product.homebase.services.HomebaseFactoryImpl_Stub.getIdentity(Unknown
    Source)
    at com.hutchison3g.core.product.homebase.client.HomebaseClient.getIdentity(HomebaseClient.java:207)
    at com.hutchison3g.core.product.homebase.client.util.HomebaseProxy.getIdentity(HomebaseProxy.java:78)
    at com.hutchison3g.core.product.homebase.client.util.UserUtil.getIdentity(UserUtil.java:132)
    at com.hutchison3g.core.product.homebase.servlets.TalonUniServlet.doGet(TalonUniServlet.java:181)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at com.hutchison3g.core.product.homebase.client.servlet.core.HomebaseCommonServlet.service(HomebaseCommonServlet.
    java:72)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6310)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3622)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2569)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    "ExecuteThread: '24' for queue: 'weblogic.kernel.Default'" daemon prio=5 tid=0x6dd548
    nid=0x24 runnable [a3d80000..a3d819
    94]
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
    - locked <c30c5010> (a java.io.BufferedInputStream)
    at java.io.DataInputStream.readByte(DataInputStream.java:276)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:189)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
    at com.hutchison3g.core.product.homebase.services.HomebaseFactoryImpl_Stub.getIdentity(Unknown
    Source)
    at com.hutchison3g.core.product.homebase.client.HomebaseClient.getIdentity(HomebaseClient.java:207)
    at com.hutchison3g.core.product.homebase.client.util.HomebaseProxy.getIdentity(HomebaseProxy.java:78)
    at com.hutchison3g.core.product.homebase.client.util.UserUtil.getIdentity(UserUtil.java:132)
    at com.hutchison3g.core.product.homebase.servlets.TalonUniServlet.doGet(TalonUniServlet.java:181)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at com.hutchison3g.core.product.homebase.client.servlet.core.HomebaseCommonServlet.service(HomebaseCommonServlet.
    java:72)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6310)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3622)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2569)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)

    Rob Woollen <[email protected]> wrote:
    Can you post the full thread dump?
    It looks like you have some code making an RMI call over the network.
    Is it calling another server, or perhaps a loopback call into the same
    server. The latter (opening a socket to your own process) is a good
    way
    to get a deadlock.
    -- Rob
    dara wrote:
    We have problems with our application which runs on bea8.1 sp1.
    Problem is that bea runs out from Threads (StuckThreads).
    thread dums look same for all threads but i can's see what is wrong.
    Here are dumps from first and last threads :
    "ExecuteThread: '1' for queue: 'weblogic.kernel.Default'" daemon prio=5tid=0x7f3628
    nid=0xd runnable [a6280000..a6281994
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
    - locked <c3197aa0> (a java.io.BufferedInputStream)
    at java.io.DataInputStream.readByte(DataInputStream.java:276)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:189)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
    at com.hutchison3g.core.product.homebase.services.HomebaseFactoryImpl_Stub.getIdentity(Unknown
    Source)
    at com.hutchison3g.core.product.homebase.client.HomebaseClient.getIdentity(HomebaseClient.java:207)
    at com.hutchison3g.core.product.homebase.client.util.HomebaseProxy.getIdentity(HomebaseProxy.java:78)
    at com.hutchison3g.core.product.homebase.client.util.UserUtil.getIdentity(UserUtil.java:132)
    at com.hutchison3g.core.product.homebase.servlets.TalonUniServlet.doGet(TalonUniServlet.java:181)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at com.hutchison3g.core.product.homebase.client.servlet.core.HomebaseCommonServlet.service(HomebaseCommonServlet.
    java:72)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6310)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3622)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2569)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    "ExecuteThread: '24' for queue: 'weblogic.kernel.Default'" daemon prio=5tid=0x6dd548
    nid=0x24 runnable [a3d80000..a3d819
    94]
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:129)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
    - locked <c30c5010> (a java.io.BufferedInputStream)
    at java.io.DataInputStream.readByte(DataInputStream.java:276)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:189)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:133)
    at com.hutchison3g.core.product.homebase.services.HomebaseFactoryImpl_Stub.getIdentity(Unknown
    Source)
    at com.hutchison3g.core.product.homebase.client.HomebaseClient.getIdentity(HomebaseClient.java:207)
    at com.hutchison3g.core.product.homebase.client.util.HomebaseProxy.getIdentity(HomebaseProxy.java:78)
    at com.hutchison3g.core.product.homebase.client.util.UserUtil.getIdentity(UserUtil.java:132)
    at com.hutchison3g.core.product.homebase.servlets.TalonUniServlet.doGet(TalonUniServlet.java:181)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at com.hutchison3g.core.product.homebase.client.servlet.core.HomebaseCommonServlet.service(HomebaseCommonServlet.
    java:72)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1053)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:387)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6310)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3622)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2569)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
    Thanks Rob,
    sorry for delay but I was on vacation.
    You are right about RMI, our app. consist from FE (front end) and BE (back end),
    comunication between them is RMI.
    We had some problems with BE but now we have new version and it looks ok.
    Anyway thanks for help, if I will have again some problems then it will be
    Help with thread analisys 2 ;-)

  • Need help with threads?.. please check my approach!!

    Hello frnds,
    I am trying to write a program.. who monitors my external tool.. please check my way of doing it.. as whenever i write programs having thread.. i end up goosy.. :(
    first let me tell.. what I want from program.. I have to start an external tool.. on separate thread.. (as it takes some time).. then it takes some arguments(3 arguments).. from file.. so i read the file.. and have to run tool.. continously.. until there are arguments left.. in file.. or.. user has stopped it by pressing STOP button..
    I have to put a marker in file too.. so that.. if program started again.. file is read from marker postion.. !!
    Hope I make clear.. what am trying to do!!
    My approach is like..
    1. Have two buttons.. START and STOP on Frame..
    START--> pressed
    2. check marker("$" sign.. placed in beginning of file during start).. on file..
         read File from marker.. got 3 arg.. pass it to tool.. and run it.. (on separate thread).. put marker.. (for next reading)
         Step 2.. continously..
    3. STOP--> pressed
         until last thread.. stops.. keep running the tool.. and when last thread stops.. stop reading any more arguments..
    Question is:
    1. Should i read file again and again.. ?.. or read it once after "$" sign.. store data in array.. and once stopped pressed.. read file again.. and put marker ("$" sign) at last read line..
    2. how should i know when my thread has stopped.. so I start tool again??.. am totally confused.. !!
    please modify my approach.. if u find anything odd..
    Thanks a lot in advance
    gervini

    Hello,
    I have no experience with threads or with having more than run "program" in a single java file. All my java files have the same structure. This master.java looks something like this:
    ---master.java---------------------------------------------------
    import java.sql.*;
    import...
    public class Master {
    public static void main(String args []) throws SQLException, IOException {
    //create connection pool here
    while (true) { // start loop here (each loop takes about five minutes)
    // set values of variables
    // select a slave process to run (from a list of slave programs)
    execute selected slave program
    // check for loop exit value
    } // end while loop
    System.out.println("Program Complete");
    } catch (Exception e) {
    System.out.println("Error: " + e);
    } finally {
    if (rSet1 != null)
    try { rSet1.close(); } catch( SQLException ignore ) { /* ignored */ }
    connection.close();
    -------end master.java--------------------------------------------------------
    This master.java program will run continuously for days or weeks, each time through the loop starting another slave process which runs for five minutes to up to an hour, which means there may be ten to twenty of these slave processes running simultaneously.
    I believe threads is the best way to do this, but I don't know where to locate these slave programs: either inside the master.java program or separate slave.java files? I will need help with either method.
    Your help is greatly appreciated. Thank you.
    Logan

  • Need some help with threads...

    Hello all,
    I am working on a project at work, and I am not the best programmer in the world. I have been trying to get my head around this for a couple of days and just cannot get it to work.
    I am writing an instrumentation control program that will have three threads. One is the GUI, one will receive control information and set up the hardware, and one will check the hardware status and report it to the GUI periodically. I plan on using the invokeLater() method to communicate the status to the GUI and change the status display in the GUI. Communication from the GUI to the controller thread and from the status thread to the controller thread I had planned on being piped input/output stream as appropriate. I have a control class and a status class that need to be communicated over these piped streams. In some trial code I have been unable to wrap the piped input/output streams with object input/output streams. I really need some help with this. Here is the main thread code:
    package playingwiththreads1;
    import java.io.*;*
    *public class PlayingWithThreads1 {*
    public static void main(String[] args) {*
    * PipedOutputStream outputPipe = new PipedOutputStream();*
    * ObjectOutputStream oos = null;*
    * ReceiverThread rt = new ReceiverThread(outputPipe);*
    // Start the thread -- First try*
    * Thread t = new Thread(rt);*
    t.start();*
    // Wrap the output pipe with an ObjectOutputStream*
    try*
    oos = new ObjectOutputStream(outputPipe);*
    catch (IOException e)*
    System.out.println(e);*
    // Start the thread -- Second try*
    //Thread t = new Thread(rt);*
    //t.start();*
    /** Send an object over the pipe. In reality this object will be a
    class that contains control or status information */
    try
    if (!oos.equals(null))
    oos.writeObject(new String ("Test"));
    catch (IOException e)
    try
    Thread.sleep(5000);
    catch (InterruptedException e)
    I read somewhere that it matters where you start the thread relative to where you wrap piped streams with the object streams. So, I tried the two places I felt were obvious to start the thread. These are noted in the comments. Here is the code for the thread.
    package playingwiththreads1;
    import java.io.*;
    public class ReceiverThread implements Runnable {
    private PipedInputStream inputPipe = new PipedInputStream();
    private ObjectInputStream inputObject;
    ReceiverThread (PipedOutputStream outputPipe)
    System.out.println("Thread initialization - start");
    try
    inputPipe.connect(outputPipe);
    inputObject = new ObjectInputStream(inputPipe);
    catch (IOException e)
    System.out.println(e);
    System.out.println("Thread initialization - complete");
    public void run()
    System.out.println("Thread started");
    try
    if (inputObject.available() > 0)
    System.out.println(inputObject.read());
    catch (IOException e)
    System.out.println(e);
    Through testing I have determined that no matter where I start the thread, the thread never gets past the "inputObject = new ObjectInputStream(inputPipe);" assignment.
    Could someone please help me with this? There are other ways for me to write this program, but this is the one that I would like to make work.
    Many thanks in advance,
    Rob Hix
    Edited by: RobertHix on Oct 6, 2009 3:54 AM

    Thanks for the help, but that did not work. I tried flushing the ObjectOutputStream and it is still hanging when initializing the thread.
    Here is a better look at the code since I was helped to figure out how to insert it:
    The main method:
    package playingwiththreads1;
    import java.io.*;
    public class PlayingWithThreads1 {
        public static void main(String[] args) {
            PipedOutputStream outputPipe = new PipedOutputStream();
            ObjectOutputStream oos = null;
            ReceiverThread rt = new ReceiverThread(outputPipe);
            // Start the thread -- First try
            //Thread t = new Thread(rt);
            //t.start();
            // Wrap the output pipe with an ObjectOutputStream
            try
                oos = new ObjectOutputStream(outputPipe);
                oos.flush();
            catch (IOException e)
                System.out.println(e);
            // Start the thread -- Second try
            Thread t = new Thread(rt);
            t.start();
            /* Send an object over the pipe.  In reality this object will be a
             * class that contains control or status information */
            try
                if (!oos.equals(null))
                    oos.writeObject(new String ("Test"));
                    oos.flush();
            catch (IOException e)
                System.out.pringln(e);
            try
                Thread.sleep(5000);
            catch (InterruptedException e)
    }The thread code:
    package playingwiththreads1;
    import java.io.*;
    public class ReceiverThread implements Runnable {
        private PipedInputStream inputPipe = new PipedInputStream();
        private ObjectInputStream inputObject;
        ReceiverThread (PipedOutputStream outputPipe)
            System.out.println("Thread initialization - start");
            try
                inputPipe.connect(outputPipe);
                inputObject = new ObjectInputStream(inputPipe);
            catch (IOException e)
                System.out.println(e);
            System.out.println("Thread initialization - complete");
        public void run()
            System.out.println("Thread started");
            try
                if (inputObject.available() > 0)
                    System.out.println(inputObject.read());
            catch (IOException e)
                System.out.println(e);
    }Does anyone else have and ideas?

  • Help with setup for live streaming

    I'm trying to set up a live stream that's viewable on my
    website.
    I have two machines behind a router with one being the
    webserver running FMS (windows 2003) and the other being the
    encoding machine running FME (windows XP).
    When I set up FME, I put in the following as the url to the
    server "rtmp://
    computernamewebserver/live/" with the session name being
    "test".
    This has no problems connecting to FMS .
    On the webserver/FMS, I created a *.swf file which basically
    contains just a flvplayback object with the URL set to "rtmp://
    computernamewebserver/live/test".
    Now after I publish this, I can view the video via the
    published html file from within the network, but when I try outside
    of the network, it doesn't work and I get no error messages so it's
    hard to debug.
    I have port 80 forwarded to my webserver/FMS machine. I tried
    forwarding port 1935 to both my webserver/FMS machine and the FME
    machine with no success.
    I've tried playing around with the rtmp URL by changing the
    computernamewebserver from the internally recognized
    computer name to the externally recognized URL to my webserver.
    The solution is probably something simple, but since this is
    my first attempt at flash streaming, it's not obvious to me and
    I've tried searching for the solution. My suspicion is that there's
    some config file somewhere that I need to config that I don't know
    about or maybe it's some port issue. Neither of my machines have
    windows based firewall disabled.

    "Now after I publish this, I can view the video..." Well this
    shows that FMS is working fine, so I am guessing that it is an
    outside network issue.
    "Neither of my machines have windows based firewall disabled.
    " I don't know if this is the cause either, as a host based
    firewall should prevent any connections from arriving, either by
    the internal lan or the external (well, at least I think that is
    the case, I dont know if windows still allows hosts on the same
    subnet to have local lan permissions or what they do with their
    crazy security model. That said it shouldn't be a problem.)
    I would try to just telnet to the port that you have open to
    make sure the connection can be established.
    telnet computernamewebserver 1935 (this should open up a
    socket, otherwise your port forwarding isnt working correctly.)
    If telnet works ok, perhaps its an issue with the swf. I
    would code the minimal things needed to just get a stream playing
    from the external network (perhaps just using the vod service, not
    the live, to make things simple).
    Hope that helps.

  • Help with Pause for Duration while in a loop

    This is my first SP 2013 work flow so am uncertain how loops after the continuation of workflows.
    I have a loop as shown below. It is part of a workflow for a Question and Answer list.  This stage checks to see whether the question has been answered.  If it has, it sends an email to the person who asked the question.  If it has not,
    it checks to see if the Answer Due Date has passed, then it sends an email to the person who was assigned to answer the question.
    I want the person who is assigned to answer the question to get a reminder email every day, thus the Pause for Duration condition.  however, if the person answers the question after receiving the reminder, it seems like the workflow would be waiting
    a day before the  person who asked their question would get their email.   Or, since the entire workflow is set to start on list item being changed, would it start over at the beginning of the workflow and thus come to completion at the
    end of the first condition in the loop?  In other words how do loops work if the list item is changed and the workflow restarted?
    There are no mistakes; every result tells you something of value about what you are trying to accomplish.

    Sorry for not being clear.
    One trick that we do is using two workflows.
    One workflow will be primary workflow just like the one you have. This will be assigned to list library, then associated to start when an item is created, and start when an item has changed.
    The second workflow will start when an item has changed, the job of this workflow is just one / two liner to update a dummy field in your list library (you may choose to name as you want kindaof Flag).
    The logic behind this is when the primary workflow starts, it will run only once, we have to invoke again. To do so you have to update the list within primary workflow after it processed the steps, else better to have secondary workflow to update the
    list with some data.
    We are just tricking the system to start over again, that's it.
    see this thread for more information-http://social.technet.microsoft.com/Forums/sharepoint/en-US/7aca6aaa-cf77-46d2-a388-6fca7adae3a7/scheduled-workflow-possible-?forum=sharepointgeneral
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

  • Wanted: Help with thread in spanish; guitar not recording

    Can someone please help with this thread?
    GarangeBand No Reconoce Mi Guitarra Audio
    The op has trouble to connect his guitar. I cannot interview him in spanish, and he does not know to ask in English.
    Appriciate any help.
    Léonie

    Hi Borris12,
    I'll clear this up for you and let you know whats happened.
    Could you drop me in an email please with your BT account and telephone number along with a link back to this thread.
    Just send to the email address in my profile and mark FAO Craig please.
    Thx
    Craig
    BTCare Community Mod
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry but we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)”
    td-p/30">Ratings star on the left-hand side of the post.
    If someone answers your question correctly please let other members know by clicking on ’Mark as Accepted Solution’.

  • I need help with my for loop in this array

    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    import javax.swing.JOptionPane;
    public class Runner
        public static void main (String[] args)
            String timeStr;
            int time, again, optiStr;
            Inbound[] in = new Inbound[25];
             in[0]=new Inbound ("",0,"On Time num0");
             in[1]=new Inbound ("",2,"On Time num1");
             in[2]=new Inbound ("",3,"Delayed num2");
             in[3]=new Inbound ("",4,"On Time");
             in[4]=new Inbound ("",5,"On Time");
             in[5]=new Inbound ("",6,"Canceled");
             in[6]=new Inbound ("",1,"Canceled num6");
             in[7]=new Inbound ("",8,"On Time");
             in[8]=new Inbound ("",9,"Delayed");
             in[9]=new Inbound ("",10,"On Time");
             in[10]=new Inbound ("",11,"Delayed");
             in[11]=new Inbound ("",12,"On Time");
             in[12]=new Inbound ("",13,"Delayed");
             in[13]=new Inbound ("",14,"On Time");
             in[14]=new Inbound ("",15,"On Time");
             in[15]=new Inbound ("",16,"On Time");
             in[16]=new Inbound ("",17,"Canceled");
             in[17]=new Inbound ("",18,"On Time");
             in[18]=new Inbound ("",19,"On Time");
             in[19]=new Inbound ("",20,"Canceled");
             in[20]=new Inbound ("",21,"On Time");
             in[21]=new Inbound ("",22,"Delayed");
             in[22]=new Inbound ("",23,"On Time");
             in[23]=new Inbound ("",24,"Cancled");
             in[24]=new Inbound ("",7,"On Time num24");
            do{
                timeStr = JOptionPane.showInputDialog ("In military time, what hour do you want?");
                time = Integer.parseInt(timeStr);
                if (time<=0 || time>24)
                 JOptionPane.showMessageDialog (null, "Error");
                 optiStr = JOptionPane.showConfirmDialog (null, "If you want Incoming flights click Yes, but if not click No");
                if (optiStr==JOptionPane.YES_OPTION)
    //(ok this is the for loop i am talking about )
                    for (int index = 0; index < in.length; index++)
                      if ( time == Inbound.getTime())
                   JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    //               else JOptionPane.showMessageDialog (null, "else");
                }//temp return else if failed to find time asked for
    //             else
    //               if (optiStr==JOptionPane.CANCEL_OPTION)
    //                 JOptionPane.showMessageDialog(null,"Canceled");
    //              else
    //                {Outbound.run();
    //                JOptionPane.showMessageDialog (null, "outbound");}//temp
                  again=JOptionPane.showConfirmDialog(null, "Try again?");
            while (again==JOptionPane.YES_OPTION);
    }any help would be greatly appriciated.

    rumble14 wrote:
    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    >//(ok this is the for loop i am talking about )
    for (int index = 0; index < in.length; index++)
    if ( time == Inbound.getTime())
    JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    Inbound.getTime() is a static method of your Inbound class, that always returns the same value, I presume? As opposed to each of the 25 members of your array in, which have individual values?
    Edited by: darb on Mar 26, 2008 11:12 AM

  • HOW DO YOU GUYS DEAL WITH APPLE.. SO CONFUSING...NEED HELP WITH SPECS FOR PURCHASE OF IMAC 21.5

    Hi guys, been reading your forums, blogposts, etc and am getting more confused.  I'm just a video girl trying to produce meaningful content through web videos for small to mid sized businesses and want to come over from the dark side. 
    Good news,, I dont need a super giant system,  I do simple editing for web videos, minimal graphics, no motion graphics, no animation etc. currently using CS4, will probably end up with 5.5.
    I want to get imac 21.5 or 27 if i have to..  So here's the question we all have,,, what do I really need besides an Apple fairy godmother to figure this crazy stuff out?????
    I want to be able to have firewire add on, but the rest is what I need help with.   So i've been looking at cs6 specs, even though im not there yet, eventually will be,, so just need to run cs4 now and build from there.  I also want to eventually move to final cut down the road so I want imac able to upgrade to final cut.
    WHAT DO I REALLY NEED MINIMALLY FOR NOW?  WHAT CAN I GET LATER IF i CHOOSE TO DO MORE AND NEED MORE POWER?
    cs6:
    Multicore Intel processor with 64-bit support
    Mac OS X v10.6.8, v10.7, or v10.8**
    4GB of RAM (8GB recommended)
    4GB of available hard-disk space for installation; additional free space required during installation (cannot install on a volume that uses a case-sensitive file system or on removable flash storage devices)
    Additional disk space required for preview files and other working files (10GB recommended)
    1280x900 display
    7200 RPM hard drive (multiple fast disk drives, preferably RAID 0 configured, recommended)
    OpenGL 2.0–capable system
    DVD-ROM drive compatible with dual-layer DVDs (SuperDrive for burning DVDs; Blu-ray burner for creating Blu-ray Disc media)
    QuickTime 7.6.6 software required for QuickTime features
    Optional: Adobe-certified GPU card for GPU-accelerated performance
    Any responses would be great.  I know you guys are busy answering the really high end tech questions

    All the current iMac models (both 21.5" and 27" with OS X Mt. Lion 10.8) will run CS4, 5.5 and 6 just fine.  They will also run Final Cut Pro X just fine.  Ditto for most any application you may want to use.
    Below are some notes (specific to your apparent requirements) that may help you with your purchase decision:
    Notes on purchasing a 21.5" iMac
    All 21.5" iMacs come with 8GB RAM but you cannot add more later.  I strongly suggest getting the maximum RAM (16GB) when you order the iMac.
    The basic hard drive is a 1TB 5400rpm drive.  It will work fine with Adobe CS but you will probably want the added speed of the optional 1TB Fusion drive for better performance. Some people will recommend/argue for one of the optional SSD drives instead, but they are very expensive and still only come in relatively small capacities - I don't recommend the SSD drives.  Get the Fusion drive and spend any extra money on a good external hard drive for backup and/or extra storage instead of an SSD.
    Notes on purchasing a 27" iMac
    All 27" iMacs come with 8GB RAM and you can add more later, up to 32GB
    The basic hard drive is a 1TB 7200rpm drive - it will be fine with Adobe CS.  There are upgrade options to a 3TB 7200rpm drive or a 1TB or 3TB fusion drive - these will be fine also.  There are also SSD drive options, but I do not recommend them. (Same comments as above.)
    Notes on all the current iMacs
    iMacs no longer come with built-in CD/DVD drives.  If you need one, you will need to purchase the Apple Superdrive accessory drive ($79)
    All of the iMac graphic processors (GPU's) are compatible with Adobe CS 4, 5.5, 6
    It is very difficult to impossible to change or upgrade the hard drive later on, so don't buy low-end thinking you can add a better internal hard drive later.
    Be aware that Macs always come with the latest (most recent) version of OS X.  And OS X Mavericks (10.9) is due to be released soon (in the next month or two).  There is no guarantee that the older Adobe CS 4 or 5.5 versions will run on OS X Mavericks.  If you cannot upgrade to CS 6 in the near future, you may want to purchase now rather than after OS X Mavericks is released.
    For what it's worth, I'd recommend the 27" iMac if your budget can afford it.  You will appreciate the larger screen size and added capabilities over the years you will use the computer.

  • Need Help with Javascript for Acrobat Pro 9

    Hello,
    I am creating a PDF form in Adobe Acrobat Profession 9.  Not having a lot of experience with Javascript, I have found this forum very helpful and have used many of the script examples for other issues I have had.  I was hoping someone could help with the following script, I have tried many variations, cannot get it to work.
    var ratio = this.getField("ratio").value
    var concentration = this.getField("concentration").value
    var result = this.getField("result").value
    if(ratio.value>=50.00)
    {result.value ='PASS';}
    if(ratio.value".value>=40.00)
    {result.value ='PASS';}
    if((concentration.value ==61) && (ratio.value >= 49.25))
    {result.value ='PASS';}
    if((concentration.value ==61) && (ratio.value >= 39.25))
    {result.value ='PASS';}
    if((concentration.value ==62) && (ratio.value >= 48.50))
    {result.value ='PASS';}
    if((concentration.value ==62) && (ratio.value >= 38.50))
    {result.value ='PASS';}
    else
    {result.value = 'FAIL';}
    This is just a piece of the code  The concentration values run from 61 through 99 and the ratio value varies for each concentration value, there is a high ratio and a low ratio.  The result of this field with populate the results field with a PASS or FAIL.  This is not working......any help is greatly appreciated!

    Thanks George.  I updated the script to:
    // Get a reference to the result field
    var ratio = this.getField("ratio");
    // Get a reference to the result field
    var concentration = this.getField("concentration");
    // Get a reference to the result field
    var result = this.getField("result");
    if(ratio.value>=50.00)
    {result.value ='PASS';}
    if(ratio.value >=40.00)
    {result.value ='PASS';}
    if((concentration.value ==61) && (ratio.value >= 49.25))
    {result.value ='PASS';}
    if((concentration.value ==61) && (ratio.value >= 39.25))
    {result.value ='PASS';}
    if((concentration.value ==62) && (ratio.value >= 48.50))
    {result.value ='PASS';}
    if((concentration.value ==62) && (ratio.value >= 38.50))
    {result.value ='PASS';}
    else
    {result.value = 'FAIL';}
    However, I am still getting a FAIL result even when the ratio is 50.00 or equal to the passable ratio.

  • Need Help With Download For Airport Express

    Ok, computer dummy here needing help with airport express. We were given airport express last night from a friend who recently purchased a newer gadget. He told us we would need to come here to download the operating system. I see lots of links to updates but no links for someone like me who has never had anything like this on my computer before. Does anyone know what link I would need to use? We have a pc with windows XP. Thanks so much for your help!

    Hello jesschambers. Welcome to the Apple Discussions!
    The AirPort Express Base Station (AX) doesn't have an "operating system" per se, but it does have built-in firmware which pretty much is the same thing. In addition, in order to administer the AX, you will need the AirPort Admin Utility for your Windows PC.
    Here are the links for the latest versions of both:
    o AirPort Express Firmware Update 6.3 for Windows
    o AirPort 4.2 for Windows

  • Need help with LikeFilter for querying the keyset instead of value

    Hi,
    I'm looking for help with the LikeFilter.
    I need to query the cache to get all entries with key starting with a particular string.
    I could see samples using LikeFilter for querying the values in the cache but not the keyset.
    Can someone help?
    E.g:
    Cache Entries:
    abc123 - value1
    abc234 - value2
    bcd123 - value3
    I want to get all entries with key starting with 'abc'.
    thanks,
    rama.

    NJ, thanks for the quick reply.
    I tried something similar (as below) but this code gives me 'java.lang.NoClassDefFoundError: com/tangosol/util/ValueExtractor'.
    KeyExtractor extractor = new KeyExtractor("getKey");
    Filter filter = new LikeFilter(extractor, id+":%",'-',false);
    -rama.
    Edited by: 911950 on Feb 2, 2012 1:18 PM

  • Need help with pagination for book

    I am working on a book and need help with the pagination. I was able to make the TOC and front matter show the numbers as Roman numerals, and the body of the text as Arabic numerals, but I can't figure out how to restart the numbering sequence for the body of the text. So the front matter is numbered i-xvi, and the text is 17-681. I need the text to start with the number 1. Each subsequent chapter is a section break as well, if that makes a difference.
    Many thanks,
    J

    Click on the page that shall start on number one. Open Inspector palette > Layout inspector (2nd tab) >
    Section > Start at: > 1

Maybe you are looking for

  • 8.6.1 install error "0x010e2754" memory could not be "read"

    I got this error when trying to install on my home machine. I tried multiple times with no joy. I think people used this disk at work already and I heard no complaints. I tried copying the entire contents of the DVD to my hard drive with the same res

  • IPhone Does Not Appear in iTunes

    Hi! My iPhone 3GS does not appear in iTunes. It is recognised by Windows. It is recognised by iTunes in my desktop PC, but the problem is when I use my Samsung NC10 portable notebook. I am using Windows XP Home, version 2002, with SP3. iTunes is vers

  • Adapters for Weblogic Integration

    Hi guys, I have some questions regarding to the adapters for WLI. In which case shall I use MQ adapter and RDBMS adapters for WLI? For example, if I use MQ with WLI domain, shall I buy MQ adapter? How about the RDBMS adapter? Thank you very much for

  • What are the SAP B1 limits

    I am looking for any official SAP information on the limitations of transaction volume supported by B1. I have a client that will be recieving 10,000 web orders per day, of one or two lines on each order. B1 can likely handle taking these orders thro

  • File icons shrunk - HELP!

    For some reason, all of my file icons have shrunk. I have gone into Finder's view preferences and my icon size hasn't changed. It is set to 44x44. For some reasons the file icons are around 20x20. Is there a way to change this back? Message was edite