#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    77
    Rep Power
    0

    Multi-threading problem



    please help me with my problem in multi threading


    ..
    how can i add method in two running thread
    i trap the thread but when i add my method in thread the program will not continue and it will not work please give me some idea on how i continue to work with it please ...
    thanks
  2. #2
  3. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,021
    Rep Power
    1285
    I don't understand your question

    Could you post an example?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    77
    Rep Power
    0
    sorry sir this actually the small part of the source that i want to add keylistener then continue execute the lower portion of the code thanks for helping

    public void thread1(){
    //scanning item
    if (scanner == true) {
    scanner = false; if(txnNoSale.trim().equalsIgnoreCase("N")){
    if (itemfound == true){
    if (itemprice != 0 && mrsTXN == false && reflectReturn == false){
    // System.out.println("enterPriceBefore="+itemprice);
    if(Double.parseDouble(itemprice) == 0.01){
    itemprice=0;
    itemPriceFree=true;

    } /* I want to add this method HERE!! but when i add this method the program will not start working and it will not continue to display what should i add to my method to continue */

    forquantity();

    /*End Method*/

    System.out.println("enterPriceAfter="+itemprice); if

    (posScreen.jlCommand.getText().trim().equalsIgnoreCase("Enter Amount") == false) itemBuffer = posScreen.jtCommand.getText().trim();

    temp_qty = quantity;
    int x = 0;
    int y = 0;
    String temp = "";

    x = mainProgram.barlen - mainProgram.codelen;
    //System.out.println("mainProgram.repeatPrev="+mainProgram.repeatPrev+"**prefixItem="+prefixItem+"**it emBuffer="+itemBuffer);
    if (mainProgram.repeatPrev.trim().equalsIgnoreCase("Y") && prefixItem == true && itemBuffer.trim().length() != 0){

    itemBuffer = Long.parseLong(itemBuffer.toString().trim().replace(".", ""))+"";
    if (itemBuffer.trim().length() == mainProgram.codelen){

    String price = Formatter.formatString(x, '0', ' ', Formatter.float2Money1(itemprice).trim().replace(".", ""));

    String skunew = itemBuffer.trim().substring(0, mainProgram.codelen)+temp+price;

    itemBuffer = skunew;

    }
    }
    KeyDefine.cFlag = true;
    posScreen.jlQTY.setVisible(false);
    posScreen.jtCommand.setText("");

    }
    }else {
    command = "";
    if (posScreen.jtqty.isVisible() == true){

    posScreen.jtqty.setText("");

    quantity = 1;

    posScreen.jtqty.setVisible(false);

    posScreen.jlQTY.setVisible(false);

    }

    }
    SearchSKU.ifok = false;
    }

    /******************************************************* * Additional condition on repeat previous item * * Previous item should not be repeated if repeatPrev=N, * * when enter key press * *******************************************************/

    if (mainProgram.repeatPrev.trim().equalsIgnoreCase("N") == true) {

    itemBuffer = "";

    }

    }
    else { popMessage.messageInformation(mainProgram.posPane, "ReScan/ReEnter Item", posScreen.jtCommand.getText());

    mainProgram.posTone.sound();

    }

    SwingUtilities.invokeLater(new Runnable() {

    public void run() {

    scanner = true;

    search = true;

    }

    });

    }
  6. #4
  7. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,021
    Rep Power
    1285
    Originally Posted by lhon12006
    sorry sir this actually the small part of the source that i want to add keylistener then continue execute the lower portion of the code thanks for helping
    When you say it won't continue, what exactly do you mean?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    77
    Rep Power
    0
    Originally Posted by bullet
    When you say it won't continue, what exactly do you mean?
    it will continue to execute the thread1 after i add method
    please help me thanks
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    77
    Rep Power
    0
    Originally Posted by bullet
    When you say it won't continue, what exactly do you mean?
    it will continue to execute and back to the thread1 after i add method

    because when i add this method
    Code:
    forquantity
    the program stop there and it will not continue the last part of thread1

    please help me thanks
  12. #7
  13. Java Junkie
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jan 2004
    Location
    Mobile, Alabama
    Posts
    4,021
    Rep Power
    1285
    Originally Posted by lhon12006
    it will continue to execute and back to the thread1 after i add method

    because when i add this method
    Code:
    forquantity
    the program stop there and it will not continue the last part of thread1

    please help me thanks
    If I understand your question correctly, the program control goes to forquantity and executes it and doesn't execute the remainder of the code?

    Is there some kind of loop there?
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    77
    Rep Power
    0
    Originally Posted by bullet
    If I understand your question correctly, the program control goes to forquantity and executes it and doesn't execute the remainder of the code?

    Is there some kind of loop there?
    from the code inside forquantity i dont have any loop but the thread1 is will continuesly loop ... do i have to add loop inside my forquantity ... how can i add loop inside of my forquantity

IMN logo majestic logo threadwatch logo seochat tools logo