Using threads and collecting responses

Hello,
I am doing multiple requests to diferent web services from diferent providers. I want to do the requests simultaneously and I think the best way is using threads. I am thinking to create a main class that creates a thread instance for every request (max 5) and then wait for the responses with a timeout. What is best way to implement this? Is there any standard or typical strategy? Different points to consider are:
- time out, the main class can't wait for ever the threads to end.
- how every thread passes the response from de web service to the main class.
Thanks in advance.

Hi,
best way to do this may be using an executor service. I cant describe this in detail here..basicly you have to create a executor
ExecutorService executor = Executors.newCachedThreadPool();then you create so called "Callables" which are like Runnables, but return a result. There you implement your thread functionality in the "call" method.
public class testCallable implements Callable{
          public Object call() throws Exception {
}in your controlling class you add these to your executor service and assign the results to a Future (which is a nonblocking operation).
    // make a new Thread for each resouce
          Future[] futures = new Future[5];
          for (int i = 0; i < 5; i++) {
               futures[i] = executor.submit(new testCallable());
          }then you retrive the result. You can assign a timeout there.
try {
             long timeoutTime = System.currentTimeMillis() + timeout;
          for (int i = 0; i < futures.length; i++) {
               long remainingTime = Math.max(0, timeoutTime
                         - System.currentTimeMillis());
               try {
                    Result result = (Result) futures.get(
                              remainingTime, TimeUnit.MILLISECONDS);
look at
http://java.sun.com/javase/6/docs/api/java/util/concurrent/ExecutorService.html
for details
Greetings
Brash

Similar Messages

  • HOW TO DISTRIBUTE FORM TO READER AND COLLECT RESPONSES IN READER

    I created a fillable form in pro at home and need to distribute to my job which only have adobe reader. How do I distribute and collect responses in my work email if the forms are filled out in reader?

    Reader doesn't do that, only Acrobat does.

  • Using Threads And Sockets

    Hello,
    I want to create a program that can send 2 or more files through the socket to the same client at the same time. Is it possible? I am trying to use threads to do this but I am not sure what to do in those threads. Should I send the socket to the thread class and create BufferedReader and DataOutputStream again in the thread?
    Also should I create threads in the client-side?
    Thanks
    Edited by: bcaputcu on May 18, 2010 2:19 AM

    bcaputcu wrote:
    Hello,
    I want to create a program that can send 2 or more files through the socket to the same client at the same time. Is it possible?No. At least not in the way you're thinking.
    I am trying to use threads to do this but I am not sure what to do in those threads. Should I send the socket to the thread class and create BufferedReader and DataOutputStream again in the thread?No, because you can't do that. The socket won't create multiple streams for your threads.
    Also should I create threads in the client-side?No.
    You need to send the files one at a time. While you could basically send the data interleaved, it would still only involve only one thread, one socket and one set of streams. And it would be a silly thing to do.

  • Using thread and socket connection with other machines

    Hi all!
    we are using weblgoic 5.1 SP9 JDK1.2.2
    we already using java.net.Socket and java.lang.Thread
    to communication TANDEM Machine on the weblogic.
    the reason why we use to socket and thread even though it is not
    recommanded is that below
    1. once we connect Socket, then we using until server shutdown or
    connection may has the problem, so we're using thread to wait
    java.io.Inputstream to read from socket.(if I using EJB, It can't
    wait socket inputstream indefinetly, because it has timeout)
    2. we're logging Database date sent or received with TANDEM Machine.
    so we need Database Access. so we using Database Access
    thru Weblogic.
    3. EJB Application using (other EJB Application - send Module)
    to send data to TANDEM Machine. So "Send Module" should
    be implemented EJB.
    but. Now I see there might be problem this framework.
    so, is there some way by just using J2EE spec, to implement this kind of
    framework.
    wait for your great help !!
    regards.

    Yes i've tried interrupt method and it doesn't have any effects on the thread... it stay in connect() method...
    And for the timeouts, in fact i use an API : J2SSH, to connect with SSH protocol, and the setting of connection timeouts is not implemented yet... and the default timeout is about 4 minutes...
    so i don't know how to solve this problem...

  • Help: Using Record and Collection Methods

    I have created a record and I have to loop for as many records in the "RECORD". However if I attempt using any of the Collection Methods, I get the following error:
    ERROR at line 1:
    ORA-06550: line 41, column 14:
    PLS-00302: component 'EXISTS' must be declared
    ORA-06550: line 41, column 4:
    PL/SQL: Statement ignored
    ORA-06550: line 47, column 26:
    PLS-00302: component 'COUNT' must be declared
    ORA-06550: line 47, column 7:
    PL/SQL: Statement ignored
    Here is the SQL I am trying to execute:
    DECLARE
    TYPE Emp_Rec is RECORD (
    Emp_Id Emp.Emp_no%TYPE
    , Name Emp.Ename%TYPE
    ERec Emp_Rec;
    Cursor C_Emp IS
    SELECT
    Emp_No, Ename
    From Emp;
    begin
    OPEN C_Emp;
    LOOP
    FETCH C_Emp INTO Erec;
    EXIT WHEN C_Emp%NOTFOUND;
    END LOOP;
    IF Erec.Exists(1) THEN
    dbms_output.Put_line('exists' );
    else
    dbms_output.Put_line('does not exists');
    end if;
    CLOSE C_Emp;
    FOR I IN 1..ERec.COUNT
    LOOP
    dbms_Output.Put_Line( 'Row: ' || To_Char(I) || '; Emp: ' || ERec(i).Name) ;
    END LOOP;
    end;
    Can anyone help, please?
    Thanking you in advance,

    You only defined a Record and not a collection, therefore you cannot use .EXISTS
    This is how you would use record, collection and exists together
    DECLARE
    TYPE Emp_Rec is RECORD
             (Emp_Id Emp.Empno%TYPE,
              EName Emp.Ename%TYPE );
    TYPE Emp_tab is table of emp_rec index by binary_integer;
    ERec Emp_tab;
    Idx  INTEGER;
    Cursor C_Emp IS
         SELECT EmpNo, Ename    From Emp;
    begin
    IDX := 1;
    OPEN C_Emp;
    LOOP
           FETCH C_Emp INTO Erec(IDX);
                     EXIT WHEN C_Emp%NOTFOUND;
           IDX := IDX + 1;
    END LOOP;
    IF Erec.Exists(1) THEN
           dbms_output.Put_line('exists' );
    else
           dbms_output.Put_line('does not exists');
    end if;
    CLOSE C_Emp;
    FOR I IN 1..ERec.COUNT  LOOP
            dbms_Output.Put_Line( 'Row: ' || To_Char(I) || '; Emp: ' || ERec(i).eName) ;
    END LOOP;
    end;I hope you realize that this is only an example of how to use RECORD, COLLECTIONS and Collection Methods (.EXISTS, .COUNT)
    and not the best way to display the contents of a table.

  • Question about using threads and synchronizing objects

    Hi all,
    I am not that familiar and I have 2 questions.
    QUESTION 1
    I have a server which just sits and accepts incomming connections, then I spawn off a new thread which implements Runnable, and then call the run method. But the loop would not iterate, it would just sit inside the run method (which has rather long loop in it). I changed the class to extend Thread and called the start() method, rather than run(), and everything worked out fine.
    Anyone know why this is?
    QUESTION 2
    So I am building a client server chat application where a user can be in multiple chat rooms. I have this personObject which has output/input streams. In the personObject, I create writeObject/ readObject method, which simply does as it implies.
    I figured that I should make these methods synchronized, to ensure things run smoothly. however, when I made a call to readObject, which sat there and waited, and then made a call to writeObject, I would not enter the writeObject method. I took out the synchronized on the writeObject, and everything worked out fine.
    I was under the assumption that synchronizing a method only synchronized on that method, not on the whole class. How come then was I not able to enter the writeObject method?
    The more I think about it, I don't think I need to have these methods synchronized, but I thought it wouldn't hurt.
    Thanks for the help.

    Hi all,
    I am not that familiar and I have 2 questions.
    QUESTION 1
    I have a server which just sits and accepts incomming
    connections, then I spawn off a new thread which
    implements Runnable, and then call the run method.
    But the loop would not iterate, it would just sit
    inside the run method (which has rather long loop in
    it). I changed the class to extend Thread and called
    the start() method, rather than run(), and everything
    worked out fine.
    Anyone know why this is?
    You should still implement Runnable, rather than extending Thread. Like this: Runnable r = new MyRunnable();
    Thread t = new Thread(r);
    t.start(); run() is just another method. Nothing special about it as far as multithreading or anything else goes.
    start() is the method that actually spawns a new thread of execution.
    I was under the assumption that synchronizing a
    method only synchronized on that method, not on the
    whole class. How come then was I not able to enter
    the writeObject method?When you synchronize, you obtain a lock. As long as you hold that lock--until you exit the sync block or call wait()--no other thread can enter that block or any other block that obtains the same lock.
    Two synchronized methods on the same object rely on obtaining the same lock--there's one lock for each object.

  • NEW! Import Fillable PDF Form and Collect Responses

    FormsCentral now allows you to import an existing fillable PDF form and use the FormsCentral service to collect and analyze the submitted data. You no longer have to recreate your existing PDF forms within the service in order to take advantage of FormsCentral’s data collection/analysis capabilities.
    You can also use popular tools like Adobe Acrobat X Pro or Adobe InDesign to create PDF forms that work with FormsCentral.
    To import a PDF form go to the “My Forms” tab, click the More button on the toolbar and select “Import PDF Form.” Note: FormsCentral does not support PDF forms created using the LiveCycle Designer (XML-based forms).
    Once imported the normal Design tab is replaced with an “Imported Form” tab that allows you to place a Submit button on the PDF form. You can place it on the top left or right of the first page, or place it on the bottom left or right of the last page. A thumbnail shows where the button will appear.
    Click to view larger image
    The Options tab shows options that are available for PDF forms (Note: PDF Forms do not support Redirect URLs or Payments so these are not shown)
    Click to view larger image
    The Distribute tab allows you to open the form and download the submit-enabled PDF file for distribution. The PDF file can be filled out, saved and submitted using the free Adobe Reader.
    Click to view larger image
    The Response and Summary Report tabs will show the data submitted from the PDF form. They function as they do for a normal form file that you created from scratch or template.
    This FAQ describes what types of PDF forms can/cannot be imported and what functionality is limited within the PDF once imported:
    http://forums.adobe.com/docs/DOC-2533
    Please send us your feedback.
    Randy

    I followed this process to import my PDF form.  The link I have on my web page is displaying an error from FormsCentral.  The link works but the web page is confusing to customers.  The message is: 
    An error has occurred.
    The form does not exist. Please re-enter the web address as the link may be misspelled.
    When I saved the submission-enabled PDF, I could only save it to my computer.  I then had to upload it to the web site server and created a link on my web page to point to that URL.  
    How can I get rid of the Adobe FormsCentral message on the web page?

  • Export/import of mappings using OMBPLUS and Collections?

    Hi,
    We've got some good TCL code to export (and import) mappings for our projects along the lines of:
    OMBEXPORT MDL_FILE '$projname.mdl' \
    PROJECT '$projname' \
    CONTROL_FILE '$controlfile.txt' \
    OUTPUT LOG '$projname.log'
    and now we're moving to organizing mappings by OWB COLLECTION and need to export/import by collection instead. Thought it might be as simple as this:
    OMBEXPORT MDL_FILE '$collname.mdl' \
    FROM COMPONENTS ( COLLECTION '$collname')
    CONTROL_FILE '$controlfile.txt' \
    but that's not working (saying "Project $collname does not exist.", so it seems to still be treating what I thought was a collection name as a project name . Can someone point out the right syntax to use COLLECTIONs in OMBEXPORT/OMBIMPORT?
    All thoughts/tips appreciated...
    Thanks,
    Jim C.

    Hi,
    If we use the below tcl script for the entire project export , does it also export the locaitons,control center,configurations along???
    If yes then can you gimme the script for altering the locations , control center/configuration connection details??
    OMBEXPORT MDL_FILE '$projname.mdl' \
    PROJECT '$projname' \
    CONTROL_FILE '$controlfile.txt' \
    OUTPUT LOG '$projname.log'
    Can you also provide me the tcl for project import??
    Thanks

  • Create a form for someone else to share and collect responses

    I created a form, but I just want to hand over to the organization to handle anything to do with it. I notice it has no button (template), required fields. They can deal with it now, once created what now??

    I am not 100% certain I understand what you are trying to do, but it sounds to me like using our export as FCDT file would allow you to do what you want. Once a form has been designed you can SaveAs FCDT and then share with the person you want to own the form going forward. They can then import your design and open the form for submission under their own account.
    Andrew

  • Connection between server and client using thread

    hi
    i am new to java..i hav done a program to connect a server and client...but i hav not used threads in it..
    so please tel me how to use threads and connect server and client..i tried it out not getin...i am havin thread exception...my program is as shown below
    SERVER PRG:
    import java.io.*;
    import java.net.*;
    public class Server{
    String clientsen;
    String serversen;
    public void go(){
    try{
         ServerSocket serverSock=new ServerSocket(6789);
         while(true) {
         Socket sock=serverSock.accept();
         BufferedReader inFromClient=new BufferedReader(new InputStreamReader(sock.getInputStream()));
         BufferedReader inFromuser=new BufferedReader(new InputStreamReader(System.in));
         DataOutputStream outToClient=new DataOutputStream(sock.getOutputStream());
         clientsen=inFromClient.readLine();
         System.out.println("From Client: "+clientsen);
         System.out.println("Reply mess to Client");
         serversen=inFromuser.readLine();
         outToClient.writeBytes(serversen+'\n');
    } catch(IOException ex) {
         ex.printStackTrace();
    public static void main(String[] args) {
         Server s = new Server();
         s.go();
         CLIENT PRG
    import java.lang.*;
    import java.util.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.net.*;
    import java.lang.Thread;
    import java.applet.Applet;
    class Client1
    public static void main(String argv[]) throws Exception
              String Sen;
              String modsen;
              BufferedReader inFromUser=new BufferedReader(new InputStreamReader(System.in));
    Socket clientSocket=new Socket("192.168.1.2",6789);
              DataOutputStream outToServer=new DataOutputStream(clientSocket.getOutputStream());
              BufferedReader inFromServer=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
              System.out.println("Enter the mess to be sent to server");
              Sen=inFromUser.readLine();
              outToServer.writeBytes(Sen + '\n');
              modsen=inFromServer.readLine();
              System.out.println("FROM SERVER: " +modsen);
              clientSocket.close();
    please send me the solution code for my problem...

    sorry for inconvenience...
    SERVER PROGRAM
      *import java.io.*;*
    *import java.net.*;*
    *public class MyRunnable implements Runnable*
       *public void run() {*
       *go();*
    *public void go(){*
    *try {*
        *String serversen;*
       *ServerSocket  welcomeSocket=new ServerSocket(6789);*
       *while(true)*
    *Socket connectionSocket=welcomeSocket.accept();*
    *//BufferedReader inFromClient=new BufferedReader(new //InputStreamReader(connectionSocket.getInputStream()));*
    *System.out.println("enter the mess to be sent to client");*
    *BufferedReader inFromuser=new BufferedReader(new InputStreamReader(System.in));*
    *DataOutputStream outToClient=new DataOutputStream(connectionSocket.getOutputStream());*
    *//clientsen=inFromClient.readLine();*
    *//System.out.println("From Client: "+clientsen);*
    *//System.out.println("Reply mess to Client");*
    *serversen=inFromuser.readLine();*
    *outToClient.writeBytes(serversen+'\n');*
    *} catch(IOException ex) {*
    *        ex.printStackTrace();*
    *class Server1{*
    *public static void main(String argv[]) throws Exception*
         *Runnable threadJob=new MyRunnable();*
    *Thread myThread=new Thread(threadJob);*
    *myThread.start();*
    *}*CLIENT PROGRAM
    import java.io.*;
    import java.net.*;
    class Client2
    public static void main(String argv[]) throws Exception
              //String Sen;
              String modsen;
              //BufferedReader inFromUser=new BufferedReader(new InputStreamReader(System.in));
    Socket clientSocket=new Socket("192.168.1.2",6789);
              //DataOutputStream outToServer=new DataOutputStream(clientSocket.getOutputStream());
              BufferedReader inFromServer=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
              //System.out.println("Enter the mess to be sent to server");
              //Sen=inFromUser.readLine();
         //     outToServer.writeBytes(Sen + '\n');
              modsen=inFromServer.readLine();
              System.out.println("FROM SERVER: " +modsen);
              clientSocket.close();
    this is the code which i hav used using thread but i am gwetin error..ts is the error
    Exception in thread "main" java.lang.NoSuchMethodError : Main

  • Forms central and collecting secure information.

    If I place a form using forces central on the internet via the collect responses online is it secure? I am collecting private information.

    How many active forms and number of responses are allowed in the standard Forms Central that comes with Adobe Acrobat XI Pro? Because I only have one active form with 3 responses (all are practices to figure out the program). If I delete everything, should I theoretically be able to upload a PDF into forms and collect responses for it? Or will that function still be blocked without an upgrade?
    Thanks for your help. Sorry for the long questions

  • Is it ever bad practice to use threads?

    Hi there ppl,
    this may sound like a really silly question is it ever bad practice to use threads? I actually have never explicitly used threads and came across a simple swing application recently which used a thread in the code. Then I started to think that if ever a scenario came up where I was expected to use threads I'd have to learn something new that I should I have already known from birth, then run and hide behind the JAVA API (which is big, real big, BIGGER THAN OPRAH!!!).
    So for now I'll "synchronise my watch" (PUN INTENDED), and await the flood of replies.
    Thx already ;)

    Main Entry: 1pun
    Pronunciation: 'p&n
    Function: noun
    Etymology: perhaps from Italian puntiglio fine point,
    quibble -- more at PUNCTILIO
    : the usually humorous use of a word in such a
    way as to suggest two or more of its meanings or the
    meaning of another word similar in sound
    emphasis mine (synchronize watch vs. synchronize
    threads)...
    Ironic that it derives from "fine point, quibble."
    &para;

  • Difference bet Thread and Runnable Inteface

    what is the main difference bet Thread and Runnable interface. Where it is used Thread and Where it is used Runnable interface

    http://www.javaworld.com/javaworld/jw-04-1996/jw-04-threads.htmlThere are a lot of differences, see the article above for details.
    Generally, I would only extend Thread if I want to enhance/extend the functionality of how Threads work (like providing a Timer or a Clock, or something). If all I am doing is providing some work to be done in a separate thread, then I will create a class that implements Runnable and run it using new Thread(myRunnable).start(). Most of the time, I use Runnable, since rarely would I need to change how threads act.

  • Threading and Re-Use of buffers Using Call By Reference node (Duct Tape required)

    I have been trying to get the following information into the public domain for years and now that I have the answers, I will share with those that may be interested.
    Warning!
    Wrap your head in duct tape before reading just for safety sakes.
    My two questions have been;
    1) can LV Re-use the buffers of the calling VI when using VI Serve Call by reference?
    2) Is the UI thread used when using Call by reference?
    1. When calling a VI using the call by reference node, does the data going into the connector pane of the node get copied, or is it in-line as it would be with a properly set up subVI?
    Short answer: It is somewhere in-between.
    Long answer:
    The compiler doesn't know what VI will be called, but it does have a hint:
    the reference wired into the Call By Reference node. It uses that to get the "Prototype" for the call. So for the best performance, use a prototype that has the same "in-placeness characteristics" as the called VI. That being said, users don't know what the "in-placeness characteristics" are.
    Before I go into the details, I should say that the overhead of these copies shouldn't matter much unless it is a large data structure (an array with a lot of elements, or a cluster/class with many fields or containing large arrays etc.).
    Example 1:
    If the prototype does not modify the data then the compiler assumes that the Call By Reference node will not modify the data. However at run-time a check is made to see if the actual called VI will modify the data. If so, then a copy is made and passed in so that the original data can remain unmodified.
    Example 2:
    If the prototype contains an input that is wired through to an output in such a way that both the input and output terminals can use the same memory buffer, but at run-time a check determines that the actual called VI's input and output do not share a buffer, then a copy will be made from the actual call's output to the original VIs (combined input and output) buffer.
    I should also mention that even with this "attempt to agree with the prototype" behavior, it's not always possible to get as good performance as a regular SubVI call. For instance if you have a situation where the prototype does not modify the data and passes it through to an output then the compiler must assume that the data is modified (because as in example 2, there exist VIs that may modify it even if the actual VI called does not).
    And there are some caveats:
    1) This "using a prototype" behavior was new to 2009. Before that we used a more naive way of passing data that assumed all inputs will be modified and no outputs share a buffer with an input.
    2) This behavior is subject to change in future versions, if we find further optimizations.
    3) This behavior is the same as we use for dynamic dispatch VIs (when using LV classes)
    4) If you want to create a VI only to be used as a prototype, then you can use features of the In-Place Element Structure to control the "in-placeness characteristics" Namely the In/Out Element border nodes, the "Mark as modifier" feature of the border nodes (note the pencil icon on the In Element), and the Always Copy node.
    5) The prototype is only the first reference ever wired into the Call By Reference node. So if you do make a new prototype VI, you can't just make a reference out of it to wire to the Call By Reference node. I suggest deleting the Call By Reference node and dropping a new one.
    6) For remote calls, we always have to "make copies" by passing data over a network.
    I hope this helps, if you want any further information/clarification, then feel free to ask.
    2. Does the call by reference node execute in the UI thread? If the call is being made by a remote machine over ethernet, which thread does the host (the machine that makes the call by reference) execute on and which thread does the target (the machine that contains the VI file) execute on?
    In the local case, the Call by Reference node does not require the UI thread and can run in whatever thread the VI wants to execute in.
    When calling a remote VI, the Call by Reference node uses the UI thread (detailed below) on both the client and on the server.
    The client uses the UI thread to send the call request to the server and then again when the response comes back. The UI thread is not blocked during the time in between.
    The server receives the TCP message in the UI thread and then starts the call in the UI thread. The server also uses the UI thread to send the response back to the client. The UI thread is not blocked on the server during the execution of the VI.
    I hope people find this when they need it!
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction
    Solved!
    Go to Solution.

    I never use duct tape. I wrap my head in aluminum foil and thus get much better shielding from the aliens trying to tap my mind.
    Also easier to remove later, but why risk taking it off??
    LabVIEW Champion . Do more with less code and in less time .

  • Example of WAIT and CONTINUE using checkBox and thread and getTreeLock()

    I had so much trouble with this that I descided to
    post if incase it helps someone else
    // Swing Applet example of WAIT and CONTINUE using checkBox and thread and getTreeLock()
    // Runs form dos window
    // When START button is pressed program increments x and displys it as a JLabel
    // When checkBox WAIT is ticked program waits.
    // When checkBox WAIT is unticked program continues.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import java.io.*;
    public class Wc extends JApplet {
    Display canvas;//drawing surface is displayed.
    Box buttonPanel;
    Box msgArea;
    public static JButton button[] = new JButton [2];
    public static JCheckBox checkBox[] = new JCheckBox[2];
    public static JLabel msg[] = new JLabel [2];
    String[] buttonDesc ={"Start","Quit"};
    public static final int buttonStart = 0;
    public static final int buttonQuit = 1;
    String[] checkBoxDesc ={"Wait"};     
    public static final int checkBoxWait = 0;
    public boolean wait;
    public Graphics g;
    //================================================================
    public static void main(String[] args){
    Frame f = new Frame();
    JApplet a = new Wc();
    f.add(a, "Center"); // Add applet to window
    a.init(); // Initialize the applet
    f.setSize(300,100); // Set the size of the window
    f.show(); // Make the window visible
    f.addWindowListener(
    new WindowAdapter(){
    public void windowClosing(WindowEvent e){System.exit(0);}
    }// end main
    //===================================================
    public void init() {
    canvas = new Display();
    setBackground(Color.black);
    getContentPane().setLayout(new BorderLayout(3,3));
    getContentPane().add(canvas, BorderLayout.CENTER);
    buttonPanel = Box.createHorizontalBox();
    getContentPane().add(buttonPanel, BorderLayout.NORTH);
    int sbZ;
    // add button
    button[0] = new JButton(buttonDesc[0]);
    button[0].addActionListener(canvas);
    buttonPanel.add(button[0]);
    button[1] = new JButton(buttonDesc[1]);
    button[1].addActionListener(canvas);
    buttonPanel.add(button[1]);
    // add checkBox
    sbZ=0;
    checkBox[sbZ]=new JCheckBox(checkBoxDesc[sbZ]);
    checkBox[sbZ].setBackground(Color.white);
    checkBox[sbZ].setOpaque(true);
    checkBox[sbZ].addActionListener(canvas);
    buttonPanel.add(checkBox[sbZ]);
    msgArea = Box.createVerticalBox(); // add message
    sbZ=0;
    msg[sbZ]=new JLabel("1",JLabel.LEFT);
    msg[sbZ].setOpaque(true);
    msg[sbZ].setBackground(Color.black);
    msg[sbZ].setForeground(Color.red);
    msgArea.add(msg[sbZ]);
    getContentPane().add(msgArea, BorderLayout.SOUTH);
    } // end init();
    //===================================================
    public void stop(){canvas.stopRunning();}
    //===================================================
    // The following nested class represents the drawing surface
    // of the applet and also does all the work.
    class Display extends JPanel implements ActionListener, Runnable {
    Image OSI;
    Graphics OSG; // A graphics context for drawing on OSI.
    Thread runner; // A thread to do the computation.
    boolean running; // Set to true when the thread is running.
    public void paintComponent(Graphics g) {
    if (OSI == null) {
    g.setColor(Color.black);
    g.fillRect(0,0,getWidth(),getHeight());
    else {g.drawImage(OSI,0,0,null);}
    }//paintComponent
    public void actionPerformed(ActionEvent evt) {
    String command = evt.getActionCommand();
    if (command.equals(buttonDesc[buttonStart])) {
    startRunning();
    if (command.equals(buttonDesc[buttonQuit])) {
    stopRunning();
    if (command.equals(checkBoxDesc[checkBoxWait])){
    System.out.println("cb");
    if (checkBox[checkBoxWait].isSelected() ) {
    wait = true;
    System.out.println("cb selected twait "+wait);
    return;
    wait = false;
    synchronized(getTreeLock()) {getTreeLock().notifyAll();}
    System.out.println("cb selected fwait "+wait);
    } // end command.equal cb wait
    } //end action performed
    // A method that starts the thread unless it is already running.
    void startRunning() {
    if (running)return;
    // Create a thread that will execute run() in this Display class.
    runner = new Thread(this);
    running = true;
    runner.start();
    } //end startRunning
    void stopRunning() {running = false;System.exit(0);}
    public void run() {
    button[buttonStart].setEnabled(false);
    int x;
    x=1;
    while(x>0 && running){
    x = x + 1;
    msg[0].setText(""+x);
    try{SwingUtilities.invokeAndWait(painter);}catch(Exception e){}
    //importand dont put this in actionPerformed
    if (wait) {
    System.out.println("run "+wait);
    synchronized(getTreeLock()) {
    while(wait) {
    System.out.println("while "+wait);
    try {getTreeLock().wait();} catch(Exception e){break;}
    } //end while(wait)
    } // end sync
    } // end if(wait)
    } // endwhile(x>0)
    stopRunning();
    } // end run()
    Runnable painter = new Runnable() {
    public void run() {
    Dimension dim = msg[0].getSize();
    msg[0].paintImmediately(0,0,dim.width,dim.height);
    Thread.yield();
    }//end run in painter
    } ; //end painter
    } //end nested class Display
    } //end class Wc

    I just encountered a similar issue.  I bought a new iPhone5s and sent my iPhone4s for recycling as it was in great shape, no scratches, no breaks, perfect condition.  I expected $200 and received an email that I would only receive $24.12.  The explanation was as follows:  Phone does not power on - Power Supply Error.   Attempts to discuss don't seem to get past a customer service rep that can only "escalate" my concern.  They said I would receive a response, but by email.  After 4 days no response.  There is something seriously wrong with the technical ability of those in the recycling center.

Maybe you are looking for

  • Macbook freezes when connecting external display

    I have tried to connect my MacBook to an external monitor, a ViewSonic VA1912wb, but the MacBook freezes each time I try. There is no opportunity to go to System Preferences with the display attached. Has anyone got an idea how to deal with this? Mac

  • Why am I getting "Associated object cannot be opened"?

    I have created a task that utilizes method CRMSALESPROCESSEDIT of standard BOR object BUS2000115 on our CRM sandbox.  As a test, I launched the Webclient UI from transaction BSP_WD_CMPWB by clicking on the Test pushbutton for component CRM_UI_FRAME. 

  • HT5395 how can i download imessage to my macbook

    how can i download imessage to my macbook

  • Drag-and-drop in J2EE

    I need to implement the drag-and-drop feature within the same page on the same web browser using J2EE. What would be the best way to do it? Thanks!

  • Best way to put binary-data into string?

    Hi there! What I want to do is to transfer binary data via HTTP/GET so what I have to do is to transfer binary data into a string. Currently I do this the follwing way:       byte[] rawSecData = new byte[4]; //any binary datas       ByteArrayOutputSt