Problems with concatenation

Hello. I'm creating a program to do synthetic division. However, I seem to be having problems in my output, as my concatenations aren't working as expected.
(I'm still at the rough stages of my program so rough codes will be all I'll be able to post)
My code:
public String divide(){
            String quotient = "";
            int dividendLength = dividend.length;
            int forMultiplication = dividend[dividendLength - 1];
            int exponent = dividendLength - 2;
            int forAddition = forMultiplication * divisor;
            quotient = forMultiplication + varUsed + "\\^" + exponent;
            exponent--;
            System.out.println("The quotient so far: " + quotient);
            System.out.println("forMultiplication: " + forMultiplication);
            System.out.println("varUsed: " + varUsed);
            System.out.println("caret: " + "\\^");
            System.out.println("exponent: " + exponent);
            int i = dividendLength - 2;
            while(i > 0){
                forMultiplication = dividend[i] + forAddition;
                forAddition = forMultiplication * divisor;
                quotient += " " + forMultiplication + varUsed + "\\^" + exponent;
                System.out.println("The quotient so far: " + quotient);
                i--;
                exponent--;
            return quotient;
        }Testing it on x^3 -12x^2 -32 / x -3, I get the following:
The quotient so far: 121\^2
forMultiplication: 1
varUsed: x
caret: \^
exponent: 1
The quotient so far: 121\^2 -9x\^1
The quotient so far: 121\^2 -9x\^1 -27x\^0My questions: How come I'm getting "21" in lieu of "x" in the first term of my output? Also, how do I print out a caret cleanly? When I try to compile with only a single backslash (id est, using the escape sequence "\^" instead of "\\^" as coded above), I get an error. Is there anything I'm missing here?
On the "21 instead of x issue": Does 21 bear any special meaning when it comes to characters/strings? Like maybe something special for regex or ascii? I'm suspecting that there is a mistake in my polynomial parsing, although I also did println's for them and they all turn out as expected.
Note: For this rough draft, I'm expecting the output: "1x^2 -9x^1 -27". The actual (and well-formatted, for which I am gunning for) answer is x^2 -9x -27 remainder 123.
Thanks in advance for any insight!

Hi paulcw. I don't know what you exactly mean by "don't quote caret". In any case, your post gave me the idea to the solution. I made the caret a character. (If that is what you mean well, the message did get through. Thanks. ^_^)
I also managed to solve the 21 issue!
See I changed the quotient assignment outside the while loop to,
quotient += forMultiplication + varUsed + '^' + exponent;And, I'd get
The quotient so far: 217
forMultiplication: 1
varUsed: x
caret: ^
exponent: 1"217" made me wonder for a while. Then it dawned on me: I am assigning an int, char, char, int to a String, initially "". Java is adding them, not concatenating. So, I changed my code to
quotient += "" + forMultiplication + varUsed + '^' + exponent;And got just what I expected.
Thanks a lot!

Similar Messages

  • Problem with concatenation, need output in a desired format

    Hi all,
    I have a weird problem with concatenation.
    I should get an output in such a way that the result would be
    Put C:\TEMP\test20090210.xml /FOLDER1/test20090210.xml
    For this first to get C:\TEMP\test20090210.xml format I said
    CONCATENATE  'C:\TEMP\test' sy-datum '.XML' INTO filepath.
    For this secondly to get /FOLDER1/test20090210.xml format I said
    CONCATENATE  '/FOLDER1/test' sy-datum '.XML' INTO filepath1.
    Now I need to get the format
    Put C:\TEMP\test20090210.xml  /FOLDER1/test20090210.xml
    And to get this I said
    CONCATENATE  'put' filepath INTO  filepath SEPARATED BY space.
    And the output for filepath was Put C:\TEMP\test20090210.xml.
    But I want u2026u2026u2026.Put C:\TEMP\test20090210.xml /FOLDER1/test20090210.xml.
    How can I achieve this?
    If I say
    CONCATENATE  filepath INTO  filepath1 SEPARATED BY space. It throws a syntax error saying
    u201CUnable to interpret filepathu201D
    Please help me..i am dying to figure out how to concatenate and get the required output.
    My filepath contains u2026 Put C:\TEMP\test20090210.xml
    My filepath1 contains u2026/FOLDER1/test20090210.xml
    I need final output asu2026u2026u2026u2026.
    Put C:\TEMP\test20090210.xml /FOLDER1/test20090210.xml
    How to attain this..please helpu2026where I am going wrong..i declared filepath and filepath1 as STRING

    Hi all,
    Thanks for immediate reply...now it works..
    but i also need to put a counter like thing to distinguish my files.
    for my filepath....
    i want it as C:\TEMP\test20090210110146 so i said....
    CONCATENATE '    C:\TEMP\test'    sy-datum s   y-uzeit  '.XML'.
    Actually i am generating XML files and naming them as testsystemdatesystemtime.
    But i am concerend that my filed might be overwrriten if a file gets generated in a fraction of a millisecond..so to avoid that now i want to put a counter.
    i.e my filepath should now be as follows each time loop executes...
    C:\TEMP\test20090210110146_1
    C:\TEMP\test20090210110147 _2
    C:\TEMP\test20090210110148 _3.........and son on how can i do it
    i.e testsystemdatesystemtime+ a counter(which tells how many times loop executed)
    Once again thanks to all for immediate help...

  • Problems with Concatenating Binary Data

    Hi
    I am experiencing a problem with the unreliable concatenation of binary data.
    I have a stored procedure that I wrote to perform cell encryption on long text fields (> 4000 characters in length). This takes the string, splits it into chunks of a set length, encrypts and concatenates the encrypted chunks into a varbinary(max) variable.
    It then stores the length of the encrypted chunk at the beginning of the data (the length of output when encrypting strings of a set length is always be the same), e.g.
    DECLARE @output VARBINARY(MAX), @length INT
    SELECT @length = LEN(@encryptedchunk1)
    SELECT @output = CONVERT(binary(8), @length) + @encryptedchunk1 + @encryptedchunk2 + @encryptedchunk3 + ...
    So far so good, and when I decrypt the data, I can read the first 8 bytes of data at beginning of the binary data to get the length of the chunk:
    -- get the length of the encrypted chunk
    SELECT @length = CONVERT(INT, CONVERT(binary(8), LEFT(@encrypteddata, 8)))
    -- then remove the first 8 bytes of data
    SELECT @encrypteddata = CONVERT(VARBINARY(MAX), RIGHT(@encrypteddata, LEN(@encrypteddata) - 8))
    <snip> code to split into chunks of length @length and decrypt
    </snip>
    This is where I am experiencing an issue. 99.4% of the time, the above code is reliable. However, 0.6% of the time this fails for one of two reasons:
    the length is stored incorrectly. The length of the encrypted chunks is usually 4052 and substituting 4052 for the returned value (4051) allows the encrypted chunks to be decrypted.
    the encrypted data sometimes starts at offset 8 instead of 9. The @length variable is correctly read at length 8 but only 7 bytes should be removed from the start, e.g.
    SELECT @length = CONVERT(INT, CONVERT(binary(8), LEFT(@encrypteddata, 8)))
    SELECT @encrypteddata = CONVERT(VARBINARY(MAX), RIGHT(@encrypteddata, LEN(@encrypteddata) - 7))
    Has anyone any ideas on why this is happening and how the process can be made more reliable?
    Julian

    Use datalength, not len. Len() is designed for character strings and will ignore trailing bytes. And count characters. Datalength does exactly what you want: it counts bytes. Look at this:
    DECLARE @b varbinary(200)
    SELECT @b = 0x4142434420202020
    SELECT @b, len(@b), datalength(@b)
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Problem with concatenation

    Hi All,
    I have 9 fields with different different lenghts. Now when I am trying to concatinate all the fields just values are concatenated which while displaying give improper results.
    Now what I want is if two fields having length of 25 and 15 respectively so on concatinating it should display result as 40 whatever the length of value is there in these fields. Lets take example: -
    Text1 = 'Problem' (Char 25)
    Text2 = 'Solving' (Char 15)
    then result should be 'Problem                  Solving        '
    I have already tried Respecting Blanks but it is giving me error saying in character mode or in byte mode or separated by expected.
    <removed_by_moderator>
    Edited by: Julius Bussche on Sep 8, 2008 12:20 PM

    Hi,
    data:
       Text1 type c length 25 value 'Problem',
       Text2 type c length 15 value 'Solving',
       text3 type string.
    CONCATENATE text1 text2
                INTO text3 separated by space.
                write: text3.
    Regards,
    Sravanthi

  • Problem with concatenating space character. Please help!

    Hi experts,
      I have requirement for creating fixed length data like this:
      Source Material.
      I am getting source value dynamically. Max size of source in 10.
    But sometime it may come as 'EMS01' and sometimes 'PLTN'. That its value can be of varied length.
    I need to concat Source and Material with space in between. The number of spaces in between is equal to 10 - current size.
    For example: If Source = 'EMS01'
       then there should be 5 spaces between source and material.
    If  source = 'PLTN'
    then there should be 6 spaces between source and material after concatenation.
    I tried like this:
    data: v_source(10),
            v_material(8),
            v_space(9),
            v_spclen type i.
    v_spclen = 10 - STRLEN( v_source ).
    DO v_spclen TIMES.
       v_space = v_space + ' '.
    ENDDO.
    CONCATENATE v_source v_space v_material INTO v_string.
    This does not work because it is putting number 0 in v_space value.
    How to resolve this? Please help!
    Thanks
    Gopal

    Hi,
    Try This.
    data: v_source(10),
           v_material(8),
           v_space(9),
           v_string(255) type c,
           v_spclen type i,
            v_spclen1 type i.            * Delcare  one more variable. This will contain Length of field  v_string after assign V_source to it.
      v_spclen = 10 - STRLEN( v_source ).
    v_string = V_source.
    CONDENSE v_string.
    v_spclen1 =  STRLEN( v_string ).
    v_spclen1 = v_spclen1 + v_spclen.   *   I have Added v_spclen1 and v_spclen to get exact position from where i will add v_material
    v_string+v_spclen1 = v_material.
        write v_string.
    Edited by: ShreeMohan Pugalia on Jul 24, 2009 3:13 PM

  • Problems with concatenated primary key

    Hi all,
    I am trying to create cache groups of single tables. When I create a cache group (using the browser based cache admin tool) for a table that has a single row primary key, there are no problems. After creating the cache group I can go to TTISQL and issue a select statement of that table to see all the rows.
    However if I create a Cache group in the same way for a table that has a concatenated primary key (using two columns), TimesTen does indeed says that the cache group is created, but then when I issue a SELECT statement for that table in TTISQL, I get "0 rows returned".
    What could be going wrong ? Please advice.
    Thanks in advance

    if you describe the cache group in ttIsql (just enter 'cachegroups;' and hit return) what do you see?
    What message do you get back if you load the cache group in ttIsql:
    load cache group <cgname> commit every 100 rows;

  • Problem with Concatened Datastore

    Hello,
    We try to implement the "Concatened Datastore". And we've got errors.
    So we download the zip file from the link "Download the kit" on the page http://www.oracle.com/technology/sample_code/products/text/htdocs/concatenated_text_datastore/cdstore_readme.html#Installation. We unzip the file and got several files.
    1) We try the "full_example" file, but the script "cdstore_10g_user" (line 12) don't exist ; sick.
    2) So, to workaround, we try to follow the instructions in the "full_example.sql" file, with little corrections :-)). We create a user test_user, we load the cdstore.sql file, and here, we'got some errors. One for table they don't exist (ORA-00942 ; the first time it's normal. New tables don't exist), and one other for an invalid identifier (ORA-00904). Here the exact log :
    Warning: Package Body created with compilation errors.
    Errors for PACKAGE BODY CTX_CD:
    LINE/COL ERROR
    48/7 PL/SQL: SQL Statement ignored
    51/16 PL/SQL: ORA-00904: "CDSTORE_NAME": invalid identifier
    3) We continue the "full_example.sql" file. Create a table mytab for the test_user, insert data into this table, drop data into cdstore. And when we try to create a new cdstore, we've got this error :
    SQL> prompt new...
    begin
    ctx_cd.create_cdstore('my2_cdstore', 'mytab');
    end;
    new...
    SQL> 2 3 4 begin
    ERROR at line 1:
    ORA-04063: package body "TEST_USER.CTX_CD" has errors
    ORA-06508: PL/SQL: could not find program unit being called: "TEST_USER.CTX_CD"
    ORA-06512: at line 2
    Is there anyone, who can tell us what's wrong ?
    Best regards
    Laurent PELLETIER

    ATTENTION ROGER FORD
    It looks like you need to make a few fixes to your full_example.sql and cdstore.sql. It looks like there are some mismatches between names of scripts and what is called and between names of tables created and selected from and so forth and some missing values for inserts. When I initially ran it with the cdstore.sql under the scott schema it ran o.k. because it was using the old definitions from the previous version, but then it wouldn't run under the test_user, so I suspect it was using the old definitions when you tested as well. After making the following corrections, it ran successfully with the test_user.
    -- changes to full_example.sql:
    --   changed password for system (not a bug)
    --   changed @cdstore_10g_user to @cdstore
    -- changes to cdstore.sql:
    --   first: 
    --     changed each occurrence of ctx_cdstore to ctx_user_cdstore
    --   then:
    --     added column cdstore_name varchar2(30) to ctx_user_cdstore_cols table:
    --       create table ctx_user_cdstore_cols (... cdstore_name varchar2(30) ...) 
    --     added cdstore_name and l_name to both inserts into ctx_user_cdstore_cols:
    --       insert into ctx_user_cdstore_cols (... cdstore_name ...)
    --       values (... l_name ...)

  • Problem with concatenated data store and VACHAR(4000) field

    Have a concatenated data store built from 18 columns in one table. The main column for the index is a VARCHAR(4000) field. When we insert more than 3215 characters in that field the row disappers from the index, 3215 characters or less works fine.
    Anyone know why?

    hi,
    If you want to display them in an input field you will need to use expression box and use the formula as store@datastorefield.
    if you want to display in the Plain text go to the display tab in the properties of plain text and use the same formula here, in plain text you can only display the values present in the datastore.
    Regards,
    Rk.

  • Problem with field GL Account is that it shows concatenated Chart of Accoun

    Hello . Please help me. We have sap BI olap universe . problem with field GL Account is that it shows concatenated Chart of Accounts. But user want to trim the chart of account and show only account in list of values in webi report.
    So What code I can put in Universe to remove this " 9000/" WHICH IS Chart of acct from GL Account
    example List of values shows
    9000/99030
    9000/99070
    I want to show as below
    99030
    99070
    I tried replace function in universe it does not work. Pls help.
    Thanks
    soniya

    Hi,
    You can do it in Web Intelligence using the function Right().
    Depending on the SAP BW version you have it is possible to build such calculated expression in universe on uniquename or name:
    <EXPRESSION>RIGHT[0CALMONTH].currentmember.uniquename,5)</EXPRESSION>
    OR
    <EXPRESSION>RIGHT([0CALMONTH].currentmember.name,5)</EXPRESSION>
    You have to replace 0CALMONTH by the unique definition of GL Accounts and you also need to use the object referencing GL Accounts in your query in addtion to the calculated expression.
    Regatds
    Didier

  • Problem with JTextPane and StateInvariantError

    Hi. I am having a problem with JTextPanes and changing only certain text to bold. I am writing a chat program and would like to allow users to make certain text in their entries bold. The best way I can think of to do this is to add <b> and </b> tags to the beginning and end of any text that is to be bold. When the other client receives the message, the program will take out all of the <b> and </b> tags and display any text between them as bold (or italic with <i> and </i>). I've searched the forums a lot and figured out several ways to make the text bold, and several ways to determine which text is bold before sending the text, but none that work together. Currently, I add the bold tags with this code: (note: messageDoc is a StyledDocument and messageText is a JTextPane)
    public String getMessageText() {
              String text = null;
              boolean bold = false, italic = false;
              for (int i = 0; i < messageDoc.getLength(); i++) {
                   messageText.setCaretPosition(i);
                   if (StyleConstants.isBold(messageDoc.getCharacterElement(i).getAttributes()) && !bold) {
                        bold = true;
                        if (text != null) {
                             text = text + "<b>";
                        else {
                             text = "<b>";
                   else if (StyleConstants.isBold(messageDoc.getCharacterElement(i).getAttributes()) && bold) {
                        // Do nothing
                   else if (!StyleConstants.isBold(messageDoc.getCharacterElement(i).getAttributes()) && bold) {
                        bold = false;
                        if (text != null) {
                             text = text + "</b>";
                        else {
                             text = "</b>";
                   try {
                        if (text != null) {
                             text = text + messageDoc.getText(i,1);
                        else {
                             text = messageDoc.getText(i, 1);
                   catch (BadLocationException e) {
                        System.out.println("An error occurred while getting the text from the message document");
                        e.printStackTrace();
              return text;
         } // end getMessageText()When the message is sent to the other client, the program searches through the received message and changes the text between the bold tags to bold. This seems as if it should work, but as soon as I click on the bold button, I get a StateInvariantError. The code for my button is:
    public void actionPerformed(ActionEvent evt) {
              if (evt.getSource() == bold) {
                   MutableAttributeSet bold = new SimpleAttributeSet();
                   StyleConstants.setBold(bold, true);
                   messageText.getStyledDocument().setCharacterAttributes(messageText.getSelectionStart(), messageText.getSelectionStart() - messageText.getSelectionEnd() - 1, bold, false);
         } //end actionPerformed()Can anyone help me to figure out why this error is being thrown? I have searched for a while to figure out this way of doing what I'm trying to do and I've found out that a StateInvariantError has been reported as a bug in several different circumstances but not in relation to this. Or, if there is a better way to add and check the style of the text that would be great as well. Any help is much appreciated, thanks in advance.

    Swing related questions should be posted in the Swing forum.
    Can't tell from you code what the problem is because I don't know the context of how each method is invoked. But it would seem like you are trying to query the data in the Document while the Document is being updated. Try wrapping the getMessageText() method is a SwingUtilities.invokeLater().
    There is no need to write custom code for a Bold Action you can just use:
    JButton bold = new JButton( new StyledEditorKit.BoldAction() );Also your code to build the text String is not very efficient. You should not be using string concatenation to append text to the string. You should be using a StringBuffer or StringBuilder.

  • I have problem with delay in serial port

    I have problem with serial port. I have connected two computers by serial port and I need to create program in Labview for transfer strings using start bits and stop bits. My problem is that my program is working quite well ...when I press start bit it starts to concatenate strings and if i press stop bits it stops...this is the purpose of this program...but problem is that it working only with delay...and need that this program dont need delay, because it can only concatenating data depends on delay from start bit....I wana solved problem with delay...I dont want using delay process in my program, but allways when I try to delete this delay it stop works correct
    here is my program

    Ok this should be simple - if I understand you correctly.
    You have the VISA session initialized with read termination character enabled.  So reading the number of bytes at port is NOT the correct way to read from the port.  Set the read number of bytes to something large (say 4096) and the read will return as soon as a termination character is received (or timeout).
    You'll need to make sure the sending device is configured to send termination character on writes (you can set that with a VISA property node)  and that you are sending the correct termination character.  The default is 0x0A (newline).
    Jeff

  • Problem with opendoc url.

    hi experts,
    i am having a problem with opendoc url in my dashboard.my url is to open a webi report depends on two prompts given by the user.
    i am using the following url and it is working fine.
    http://sysname:port/OpenDocument/opendoc/openDocument.jsp?sType=wid&sRefresh=Y&iDocID=123456&mode=full&nbPrompts=2&lsSEnter Year=Prompt1&lsSEnter Dealer=prompt2.
    when i am entering a value for prompt2 like "krishna distributors" its working fine.but the problem here is whenever i am entering a value for the second prompt with a value like (ex:) "ravi & ravi distributors" its giving an message "NO DATA TO RETRIEVE"  because it is considering the & symbol in my prompt2 as another parameter as shown below.
    http://sysname:port/OpenDocument/opendoc/openDocument.jsp?sType=wid&sRefresh=Y&iDocID=123456&mode=full&nbPrompts=2&lsSEnter Year=Prompt1&lsSEnter Dealer=ravi & ravi distributor
    can anyone help me on this.
    thanks in advance,
    ravi kishore yarramsetti.

    Hi Ravi,
    In Excel , & considers as "Concatenation. So it will not work properly. To make this work, use Dealer Number instead of Dealer name in ur example.
    Eg:
    Dealer Name                           Dealer Number
    ravi & ravi distributors            D10001
    krishna distributors                 D10002
    If you use Dealer Number "D10001" you can get "ravi & ravi distributors " Information. In ur Dashboard Design, if the user clicks "ravi & ravi distributors" then pass "D10001" to the Opendoc and generate the report.
    Try to not use which has special characters as the prompt in Xcelsius.
    Thanks,
    Muthukumar A.S.

  • Problems with recordset paging and dynamic menu displaying all the options

    Hi hope someone can help on this - I've posted the code on the FoEd Backend Blight - with no takers/success yet -
    I've created a jobs page using DWCS3 which has a dynamic drop down menu filtering the 'countries' that jobs are located in.  When I introduce a recordset page only those countries associated with the jobs on that particular page are shown in the dynamic menu above, not all of the countries listed in the database. When I get to the second page of results - again - only those jobs' countries are shown in the menu (and not the previous pages/next pages as well).
    I'd clearly like a user to be able to select from the menu of countries available for all the jobs in the database, and not just those on the page.  Any ideas?
    On a similar strain - my country menu/filter is wrapped up in a form above the list of jobs.  On loading the page, only the search and menus appear.  No jobs are shown until I hit submit.  Is there a way to have all the jobs display on first load, and then for the search/menu filter to work on the displayed jobs. I've tried altering the variables on the search to 1 from -1, and other options but I can't seem to get a page of content on first load.
    I'd really appreciate any pointers on the above, as this would help solve the final stage of my project. The full post and code can be seen on the friendsofed website under backend blight.
    Many thanks in advance.
    Matt

    I'm still stuck on getting the page to load with some actual content, however.  I'm just getting the search box and country filter displaying on first load.
    Pages 584-6 explain why you get nothing when a page first loads. Dreamweaver sets the default value to -1. The problem with trying to change the default value even to an empty string or % is that Dreamweaver's security function, GetSQLValueString() changes an empty string to NULL and wraps % in quotes, so neither will work.
    One way to display all records when the page first loads is to create another recordset that selects all records. Wrap the code in a conditional statement that checks whether the $_GET array contains any values:
    if (!$_GET) {
      // recordset to retrieve all records here
    This means that you need two repeat regions to display the results. Wrap both of them in conditional statements:
    if (isset($fullRecordsetName)) {
      // display the full recordset
    } elseif (isset($searchResultsRecordsetName)) {
      // display the search results
    You also need to wrap the mysql_free_result() statements in conditional statements at the end of the page:
    if (isset($fullRecordsetName)) mysql_free_result($fullRecordsetName);
    if (isset($searchResultsRecordsetName)) mysql_free_result($searchResultsRecordsetName);
    Another way to do it is to use just one recordset, but split the SQL query into two sections:
    $query_RecordsetName = "SELECT * FROM myTable";
    if (isset($_GET['searchTerm')) {
    $query_RecordsetName .= sprintf(" WHERE searchTerm LIKE %s",
         GetSQLValueString("%" . $colname_RecordsetName . "%", "text"));
    This uses the combined concatenation operator to add the WHERE clause to the query only if $_GET['searchTerm'] has been set. Notice that you need a space before the "WHERE".

  • Problem with Emailing the Internal table data as an excel attachment

    Hi Friends,
    I am facing problem with Emailing an internal table data as an excel file. I am using standard function module "SO_NEW_DOCUMENT_ATT_SEND_API1" which is using SOLI structure can have record with 255 character length. But my Internal table having each record means after concatenating all the fields it is going to be morethan 450 characters. so i t is not displaying all the data in excel file.
    Can somebody help me if there is any other function module or any other way that i need to follow.
    thanks for help
    venkat.

    You must use the the :
    CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB as a field seperator and
    CL_ABAP_CHAR_UTILITIES=>CR_LF as a record seperator.
    Check this example:
    http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
    Regards,
    Naimesh Patel

  • A problem with threads

    I am trying to implement some kind of a server listening for requests. The listener part of the app, is a daemon thread that listens for connections and instantiates a handling daemon thread once it gets some. However, my problem is that i must be able to kill the listening thread at the user's will (say via a sto button). I have done this via the Sun's proposed way, by testing a boolean flag in the loop, which is set to false when i wish to kill the thread. The problem with this thing is the following...
    Once the thread starts excecuting, it will test the flag, find it true and enter the loop. At some point it will LOCK on the server socket waiting for connection. Unless some client actually connects, it will keep on listening indefinatelly whithought ever bothering to check for the flag again (no matter how many times you set the damn thing to false).
    My question is this: Is there any real, non-theoretical, applied way to stop thread in java safely?
    Thank you in advance,
    Lefty

    This was one solution from the socket programming forum, have you tried this??
    public Thread MyThread extends Thread{
         boolean active = true;          
         public void run(){
              ss.setSoTimeout(90);               
              while (active){                   
                   try{                       
                        serverSocket = ss.accept();
                   catch (SocketTimeoutException ste){
                   // do nothing                   
         // interrupt thread           
         public void deactivate(){               
              active = false;
              // you gotta sleep for a time longer than the               
              // accept() timeout to make sure that timeout is finished.               
              try{
                   sleep(91);               
              }catch (InterruptedException ie){            
              interrupt();
    }

Maybe you are looking for