A method completes partially???

Hi
I'm using a method developped by myself
which compares two arrays and if there are equal items
deletes them all and returns an array of items that were not in any of the compared arrays.
But, my program executes those methods many times in a row, always returning the array to the same variable.
Something like:
myarr = inst.compare(myarr_1,myarr);
myarr = inst.compare(myarr_2,myarr);
myarr = inst.compare(myarr_3,myarr);
It should be okay, but it isn't. There are repeating items after all.
What did I do wrong?
Thanks

whole function and prototype means the entire method, including its definition (you know, 'public void bah ()...')
It's not possible to tell from your code what the problem is, but my suggestion is that to remove duplicate values, you must first order the arrays in some way that you don't have to search every element every time.

Similar Messages

  • Messages "Item completely/partially delivered on purchasing documents

    Dear,
    We're testing the new layouts of the purchase documents for the upgrade to ECC 6.O and there is a problem with a specific message on item level.
    If a purchase order is changed, a message "Item completely delivered" or "Item partially delivered" occurs on the document, that isn't the case in our PRD - system. 
    I already deleted messages P14 and P15 in SPRO => MM => Purchasing => Messages => Change Texts (Item completely/partially delivered) but the messages still appear when the document has been changed (when a goods receipt is done,...). 
    Does anyone knows where I can change the settings so this text won't occur anymore?
    Thanks in advance!
    Kind Regards,
    Lien Van de Velde

    Hi
    Ae you using the same layout & print program that is in Productions, as these texts come only with the Standard Print program & form.
    Please check the same in Define Message Types for Purchase Order
    Thanks & Regards
    Kishore

  • @Xml... annotation telling schemagen to ignore a method completely

    Hi all,
    I write Java Beans and annotate them by @Xml... annotations in the source code. I am able to generate a proper schema from the classes and to marschal a class into a XML document, etc.. I am missing one thing: I would like the marshalable classes to have some methods which would be totally ignored during generating the schema, marshalling and unmarshalling and which could use any classes not described and not included in the schema. Actually, I am wrinting a persistent representation of classes which I cannot change as they are a part of a JAR distribution - I would like the Java Bean classes to have methods for a creation of the non-persistent classes which the persistent classes represent.
    I am missing a @Xml... annotation that would tell the schemagen, Marshaller and Unmarshaller to ignore these methods (no matter what types of classes they return, use as parameters). The @XmlTransient seemed to be the closest one, but it is not applicable to methods. Does there exist an annotation for or just a way of having such methods in a marshallable class that would be completelly ignored by JAXB 2.0? (I assume that e.g. during unmarshalling is taken the appropriate class and the properties are initialized in accordance to the content of the XML document and methods are not affeted anyhow.)
    Thanks,
    Bebe

    peter at knowhowpro wrote:
    DHWachs wrote:
    This post was great!  Thank you so much.  But I am hoping you know one more thing related to this.  In the "transform" section of the definition (where the x/y coordinates are set along with height and width) there is an option called "angle".  I was hoping that changing this value would allow me to offset the angle of the picture.  However, if I put any value there other than 0 the template becomes unusable.
    Do you happen to know what this option does?
    I haven't looked into the files, so this is just a guess based on how some graphic applications work. It's common to think of rotating a shape as pivoting around a center point, but It's possible that the file sets a value for the rotation point not at the center. In some graphics applications, you can set a shape's pivot at any corner or in the middle of any side, of the rectangle that contains the whole shape.
    So, your value may be rotating the shape around a pivot that moves the shape into some area that upsets the behavior of other shapes. Just a thought.
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices
    Peter's point is a good one.  I would also assume that the "angle" property allows you to rotate an image, but I haven't tried it myself.  One thing to investigate - are there any page templates included in LR that have image placeholders that are at an angle (I don't recall any, off-hand)?  If so, looking at the associated .lua file could provide insight into how an angled image placeholder should be described.

  • How do I complete partially purchased album?

    Have followed the complete purchase steps indicated in the iTunes store but unsuccessful.

    hello 1Presence, we can only answer questions related to mozilla products in this forum. if you are having questions about the itunes purchasing process you'd need to contact apple's support instead.
    thank you!

  • Help!! I am new to Java and just don't know enough to complete my project!!

    Hi, I need help! Below is listed my code for a bar code scanning project that my company has asked me to write. I want to read a barcode, make sure that it is not already in my file, if not in file write to file(this part works - the write to file), if in file pop up an error message. I am reading barcodes off pallets of boxes and need to reset the current pallet after it is complete but don't reset the total pallets until exit. Could you please look at my code -- the first half of the code is the GUI -- and make suggestions. My vectors are not working and I have not completed the error handeling. I need to finish by Friday. Tall order for someone who has only had the basics and this is my first project. Sorry I don't have any Duke dollars left -- so this one is for free.
    //-------------------Buffalo Offline Scan Program------------
    //This program will allow the Buffalo user to continue scanning cases on pallets
    //when the AS\400 is down. The scans will be sent to a flat file that will be
    //FTPed to the AS\400 when it is back up and update the proper files.
    //Program Author: Susan Riggin and Dean Smith
    //RFSS # 01080701
    package javalab;
    import javabook.*;
    import javalab.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.applet.*;
    import java.io.*;
    import java.io.File.*;
    import java.util.*;
    public class Bscan extends Applet implements ActionListener//, TextListener
    //               Data Members
         //Variables
         private int scanCount = 0;
         private int sessionCount = 0;
         //Labels
         private Label buffaloLabel = new Label();
         private Label scanLabel = new Label();
         private Label cPalletLabel = new Label();
         private Label cCountLabel = new Label();
         private Label tPalletLabel = new Label();
         private Label tCountLabel = new Label();
         private Label rButtonLabel = new Label();
         private Label eButtonLabel = new Label();
         private Label caseCountLabel = new Label();
         private Label pButtonLabel = new Label();
         private Label errorLabel = new Label();
         //TextFields
         private TextField scanTextField = new TextField();
         private TextField caseCount = new TextField("0");
         //Buttons
         private Button eButton = new Button("Exit");
         //Text Areas
         private TextArea cTextArea = new TextArea();
         private TextArea tTextArea = new TextArea();
         String scanText = scanTextField.getText();
         Vector v = new Vector(24,5);
         Vector v2 = new Vector(24,5);
    //               Constructor
    public Bscan()
         //Attach the GUI objects so they will appear on the screen.
         setLayout (null);
         buffaloLabel.setBounds(203, 5, 300, 27);
         buffaloLabel.setFont(new Font ("dialog",Font.BOLD, 18));
         buffaloLabel.setAlignment(Label.CENTER);
         buffaloLabel.setBackground(Color.red);
         buffaloLabel.setText("Buffalo OffLine Scan");
         cPalletLabel.setBounds(18, 60, 341, 23);
         cPalletLabel.setFont(new Font ("dialog", Font.BOLD, 14));
         cPalletLabel.setAlignment(Label.CENTER);
         cPalletLabel.setText("Current Pallet");
         cPalletLabel.setBackground(Color.cyan);
         tPalletLabel.setBounds(372, 62, 341, 23);
         tPalletLabel.setFont(new Font ("dialog", Font.BOLD, 14));
         tPalletLabel.setAlignment(Label.CENTER);
         tPalletLabel.setText("Total Pallets");
         tPalletLabel.setBackground(Color.yellow);
         eButton.setBounds(542, 485, 56, 23);
         eButton.setBackground(Color.yellow);
         eButton.setLabel("Exit");
         cCountLabel.setBounds(18, 88, 341, 23);
         cCountLabel.setFont(new Font("dialog", Font.BOLD, 12));
         cCountLabel.setAlignment(Label.CENTER);
         cCountLabel.setText("Current Pallet Case Count = " + scanCount);
         cCountLabel.setBackground(Color.lightGray);
         tCountLabel.setBounds(372, 88, 341, 23);
         tCountLabel.setFont(new Font("dialog", Font.BOLD, 12));
         tCountLabel.setAlignment(Label.CENTER);
         tCountLabel.setText("Total Pallet Case Count = " + sessionCount);
         tCountLabel.setBackground(Color.lightGray);
         scanLabel.setBounds(360, 33, 160, 23);
         scanLabel.setFont(new Font("dialog", Font.BOLD, 14));
         scanLabel.setBackground(Color.red);
         scanLabel.setAlignment(Label.CENTER);
         scanLabel.setText(" Current Barcode Scan: ");
         caseCountLabel.setBounds(18, 33, 200, 23);
         caseCountLabel.setFont(new Font("dialog", Font.BOLD, 14));
         caseCountLabel.setBackground(Color.red);
         caseCountLabel.setAlignment(Label.CENTER);
         caseCountLabel.setText("#Parts in Case:");
         caseCount.setBounds(250, 34, 58, 23);
         caseCount.setBackground(Color.white);
         scanTextField.setBounds(545, 34, 88, 23);
         scanTextField.setBackground(Color.white);
         eButtonLabel.setBounds(372, 460, 341, 23);
         eButtonLabel.setAlignment(Label.CENTER);
         eButtonLabel.setBackground(Color.yellow);
         eButtonLabel.setText("Press Exit to end Program.");
         rButtonLabel.setBounds(18, 460, 341, 23);
         rButtonLabel.setAlignment(Label.CENTER);
         rButtonLabel.setBackground(Color.cyan);
         rButtonLabel.setText("Scan Reset barcode for next pallet scan.");
         pButtonLabel.setBounds(200, 485, 315, 23);
         pButtonLabel.setAlignment(Label.CENTER);
         pButtonLabel.setFont(new Font ("dialog", Font.BOLD, 12));
         pButtonLabel.setBackground(Color.green);
         pButtonLabel.setText("Scan Partial Case Bar Code to enter correct # parts.");
         errorLabel.setBounds(18, 500, 682, 25);
         errorLabel.setAlignment(Label.CENTER);
         errorLabel.setFont(new Font ("dialog", Font.BOLD, 16));
         errorLabel.setBackground(Color.red);
         errorLabel.setText("Error - Barcode already scanned - scan next box!!!");
         cTextArea.setBounds(18, 118, 341, 333);
         cTextArea.setBackground(Color.cyan);
         tTextArea.setBounds(372, 118, 341, 333);
         tTextArea.setBackground(Color.yellow);
         //Place the GUI objects on the applet.
         add(buffaloLabel);
         add(scanLabel);
         add(cPalletLabel);
         add(cCountLabel);
         add(tCountLabel);
         add(tPalletLabel);
         add(cCountLabel);
         add(rButtonLabel);
         add(eButtonLabel);
         add(pButtonLabel);
         add(caseCountLabel);
         add(scanTextField);
         add(caseCount);
         add(eButton);
         add(cTextArea);
         add(tTextArea);
         //Add applet as an action listener.
         //caseCount.addTextListener(this);
         caseCount.addActionListener(this);
         scanTextField.addActionListener(this);
         eButton.addActionListener(this);
    //               Methods that make the program work
    //-------method adds the Abbott "A" and Buffalo to the screen--
         //Adds the Abbott "A" & Buffalo to the screen
         public void paint(Graphics g){
         Toolkit kit = Toolkit.getDefaultToolkit();
         Image imageA = kit.getImage("c:\\\\javaproj\\javalab\\abbott.gif");
         Image imageB = kit.getImage("c:\\\\javaproj\\javalab\\bison.gif");
         g.drawImage(imageA, 650, 5, 50, 50, this);
         g.drawImage(imageB, 713, 5, 50, 50, this);
    //---------method for action performed and action event---------
         public void actionPerformed(ActionEvent event)
         String scanText,caseb, cTime, cDate, pCount;
         scanText = scanTextField.getText();
         caseb = caseCount.getText();
         caseCount.setText("0");
         //tests the barcode to see if reset or count needed
         if (event.getSource() == eButton) exit();
         else     
         if (scanText.equals ("99999999999999")) reset();
         else
         if (scanText.equals ("88888888888888")) count();
         else
         checker();
         //scanText = scanTextField.getText();
         Clock myClock = new Clock();
         cTime = myClock.getCurrentTime();
         cDate = myClock.getCurrentDate();
         ++scanCount;
         ++sessionCount;
         pCount = caseb;
         File scan = new File ("\\\\beast2\\riggisl\\scan", "scan.txt");
         cTextArea.append(scanCount+"->"+scanText+" "+cDate+" "+cTime+" "+pCount);
         cCountLabel.setText("Current Pallet Case Count = " + scanCount);
         cTextArea.append("\r\n");
         tTextArea.append(sessionCount+"->"+scanText+" "+cDate+" "+cTime+" "+pCount );
         tCountLabel.setText("Total Pallet Case Count = " + sessionCount);
         tTextArea.append("\r\n");
         write();
         scanTextField.setText("");
    //-------------method for pressing the exit button---------------
         private void exit()
         v.clear();
         System.exit(0);
    //------------method for pressing the reset button---------------
         private void reset()
         scanCount = 0;
         scanTextField.setText("");
         cTextArea.setText("");
         cCountLabel.setText("Current Pallet Case Count = " + scanCount);
         scanTextField.requestFocus();
         v.clear();     
    //------------method for writing to the file---------------------
         private void write ()
         String cTime, cDate;
         Clock myClock = new Clock();
         cTime = myClock.getCurrentTime();
         cDate = myClock.getCurrentDate();
         String pCount = caseCount.getText();     
              try
         //FileWriter outputFile = new FileWriter("\\\\bfpscr01\\ftpdata\\scan\\scan.txt", true);
         //FileWriter outputFile = new FileWriter("c:\\\\javaproj\\javalab\\scan.txt", true);
         FileWriter outputFile = new FileWriter("\\\\beast2\\riggisl\\scan\\scan.txt", true);
         outputFile.write(scanTextField.getText());
         outputFile.write(myClock.getCurrentDate());
         outputFile.write(myClock.getCurrentTime());
         outputFile.write(pCount);
         outputFile.write("\r\n");
         outputFile.close();
    catch (IOException e)
         scanTextField.setText("");
    //               method for partial case count
         public void count()
         String caseb, scanText;
         caseCount.setText("");
         scanTextField.setText("");
         caseb = caseCount.getText();
         scanText = scanTextField.getText();
         checker();
    //               method for error
         public void error()
         add(errorLabel);
    //               method for checking barcode
         public void checker()
         String barcode = scanText;
         v.add(barcode);
         if(v == v2)
         error();
         else
         v2.add(barcode);
    }     

    I have a feeling you've already figured it out but I'll give a quick example. I didn't see where you're actually reading from the scan.txt file so I'm assuming that you're starting from scratch every time. It seems to me that you only need one Vector too - the one that contains all of the previously scanned codes.
    Let's rename v to scannedList.
    public void checker() {
      String barcode = scanText;
      if (scannedList.contains(barcode)) {
        error();
      else {
        scannedList.add(barcode);
        // write barcode to file
    }You might want to read the scan.txt file on program startup and fill the scannedList with the codes already there:
    Vector scannedList = new Vector();
    BufferedReader f = new BufferedReader(new FileReader("scan.txt"));
    String line;
    while ((line = f.readLine()) != null) {
      scannedList.add(line);
    f.close();

  • Errors with Time Machine (not completing backup, and needing to erase the ".inProgress" package)

    I have in a previous discussion been talking about errors with my Time Machine backup.  The errors were with a problem with Indexing a file, it fails and stops the whole backup.  Each time it attemps another backup, it fills my ".inProgress" package with a (nearly) whole backup, filling my Time Machine hard drive, and thus errasing my previous good backups.  The error occurs after about 95% completion.
    In my last post of a similar disscussion, the problem was indexing the Preference Pane files and this caused the whole backup to fail.  This was my last post there:  (below in some additional info of my situation)
    I did exclude the MobileMe.prefPane.  And I got:
    12/16/11 9:24:50.468 PM com.apple.backupd: Starting standard backup
    12/16/11 9:24:50.556 PM com.apple.backupd: Backing up to: /Volumes/3 TB GoFlex Drive/Backups.backupdb
    12/16/11 9:25:14.418 PM com.apple.backupd: Waiting for index to be ready (101)
    12/16/11 9:27:02.366 PM com.apple.backupd: Deep event scan at path:/ reason:must scan subdirs|
    12/16/11 9:27:02.366 PM com.apple.backupd: Finished scan
    12/16/11 9:33:37.119 PM com.apple.backupd: Deep event scan at path:/Volumes/Mac OS Lion GM reason:must scan subdirs|
    12/16/11 9:33:37.119 PM com.apple.backupd: Finished scan
    12/16/11 9:36:15.650 PM com.apple.backupd: 758.92 GB required (including padding), 830.32 GB available
    12/16/11 10:25:14.873 PM com.apple.backupd: Copied 22.8 GB of 630.5 GB, 782749 of 2357620 items
    12/16/11 11:25:15.335 PM com.apple.backupd: Copied 86.6 GB of 630.5 GB, 1167675 of 2357620 items
    12/17/11 12:25:16.227 AM com.apple.backupd: Copied 152.2 GB of 630.5 GB, 1393795 of 2357620 items
    Dec 17 01:25:16 Thomas-P-Kellys-iMac com.apple.backupd[99858]: Copied 305.2 GB of 630.5 GB, 1413946 of 2357620 items
    Dec 17 02:25:16 Thomas-P-Kellys-iMac com.apple.backupd[99858]: Copied 457.1 GB of 630.5 GB, 1419190 of 2357620 items
    Dec 17 03:19:07 Thomas-P-Kellys-iMac com.apple.backupd[99858]: Copied 1736865 files (568.3 GB) from volume Macintosh HD.
    Dec 17 03:25:16 Thomas-P-Kellys-iMac com.apple.backupd[99858]: Copied 572.1 GB of 630.5 GB, 1848939 of 2357620 items
    Dec 17 03:40:33 Thomas-P-Kellys-iMac com.apple.backupd[99858]: Indexing a file failed. Returned 200 for: /Volumes/Mac OS Lion GM/System/Library/PreferencePanes/Mouse.prefPane, /Volumes/3 TB GoFlex Drive/Backups.backupdb/Tom iMac/2011-12-14-171406.inProgress/7DB524DD-EFB9-42A6-8A21-0A2A312EDA6D/Mac OS Lion GM/System/Library/PreferencePanes/Mouse.prefPane
    Dec 17 03:40:33 Thomas-P-Kellys-iMac com.apple.backupd[99858]: Aborting backup because indexing a file failed.
    Dec 17 03:40:33 Thomas-P-Kellys-iMac com.apple.backupd[99858]: Stopping backup.
    Dec 17 03:40:33 Thomas-P-Kellys-iMac com.apple.backupd[99858]: Copied 2164998 files (581.1 GB) from volume Mac OS Lion GM.
    Dec 17 03:40:33 Thomas-P-Kellys-iMac com.apple.backupd[99858]: Copy stage failed with error:11
    Dec 17 03:40:50 Thomas-P-Kellys-iMac com.apple.backupd[99858]: Backup failed with error: 11
    This time it was the Mouse.prefPane that caused the error.  I'd like to exclude the entire PreferencePanes directory.
    This was my error message this time:
    I just realized this was on my small Developers partition.  Perhaps there is an error with the build, OR an error with the initial restore.  I'd like to perhaps exclude the entire /Volumes/Mac OS Lion GM.  I expect that Time Machine is working fine with my main partition and the error happens when it's almost done with the Mac OS Lion GM partition.
    The problem now is that I only have 265 GB of 3 TB available on my Time Machine HDD.  If attempt another backup, it'll surely erase about 410 GB of my past saved backups.  I've already lost 6 months, and I only have two months left of backups.  I need to erase the ".inProgress" package again.  That'll take time, and it's impossible to do from this main partition, even at root access.  This ".inProgress" has a total of two (nearly) full backups; it didn't cleanup the first full backup attempt while starting the second,perhaps it would have had it finished.  But I fear even if I exclude the whole "Mac OS Lion GM" partition,  It'll create a third full backup before cleanup and erase ~400 GB of previous good backups.  Then, I'll have a total of 4 (nearly) full backups!  3 TB is just enough without any past backups.
    Maybe I'll just copy my documentations of my 'errasing the ".inProgress" package'  last time (from the Mac OS Lion GM partition) and do a full restore of just that partition.  Thus erasing the errors all together.  If it doesn't fix the errors then this could be a bug in the build that doesn't allow Time Machine to work.  I've always included this partition in Time Machine before, even with other Lion builds, so I suspect that it was an error in the initial restore.  (I may be answering my own questions, and that the inital restore (of the small partition) is the problem, and I just need to re-restore the small partition)
    Again, I'm going to have to erase the ".inProgress" file to regain 1.53 TB of space before proceeding.
    Also, I gave myself permission to read the ".Backup.345781513.887697.log", the log that was created last night when I first started Time Machine this last time.  It was interesting, but didn't show the error I could see from the console.
    Right now, mds and mdworker appear to be going crazy even after I just now turned off Time Machine.  I think I'll let it go for the rest of the night.  Then I'll work on erasing the ".inProgress" package from the other partition boot up.
    That was my entire last post.  To add some information, I have two OS X partitons, both Mac OS X Lion.  One is my large main partition, the other is one I don't mind testing with.  I recently replaced my internal hard drive in my iMac and restored from Time Machine both partitions.  This appeared to go smoothly.  But I have yet to create a single successful Time Machine backup since.  At first it was doing a Full Backup, which I didn't like, but now it just aborts around 95% completion.  Each, time, it tries it fills the Time Machine hard drive with duplicate (nearly) full backups errasing my older good backups.  I would like to erase the ".inProgress" file to save space.
    My main question in this new discussion is does anyone know of a good way of erasing the ".inProgress" file? This is so I can preseerve my previous backups.  ACLs and other permissions seem to make it impossible to erase from this startup partition, the one I'm running Time Machine from.  Even at root level, if I give myself permission to change permissions or delete a file, it'll say Operation not Permitted instead of Permission Denied.  I have been able to delete this ".inProgress" package before when booting from the other  partition, but with great difficulty.  I have had much help from another Member in this Support Community when it comes to solving my Time Machine problems.  I think I have found the problem (indexing files in my small OS X partition), as stated in my copy& pasted post above, but I really need to delete this inProgress package first to save space before continuing!

    Pondini wrote:
    Gator TPK wrote:
    Now I'll have to fix the small partition?  How's the best way to do this?  There could be thousands of files that won't index fine.
    See if there's anything you haven't done, that applies, in the pink box of #C3 in Time Machine - Troubleshooting
    Otherwise, since most (or all?) of the indexing errors are in OSX, you might want to just reinstall it.  Something may have gone wrong sometime, that damaged those files.
    I reviewed #C3 in Time Machine - Troubleshooting and I have already done most of those things.  I have just learned something new though:
    When I included my Main OS X partition again, I got an indexing error for the first time for that partition.  I might be interesting to note that the _spotlight process was running, and it's running again (the magnifying glass has a dot and it generically says "Indexing Tom's iMac").  mdworker, mds and backupd processes really are working hard, one moment they used over 500% of my CPU.  It's nice to know for once quad core is good for something other than video encoding.  (Now if they could just get the Finder to do more than 100.1%, only 1 thread is doing 100%, I'd like to see file size calculations 8 times quicker!)
    I never got an indexing error once in the past 2 weeks for that large Mac OS X v10.7.2 main volume, and it had appeared to finish that partition backup before running into problems with my smaller test partition.  Also, I had just updated the smaller test partition with a later build of Mac OS X.  But It appears that the beta builds are clearly not the problem.  I thought I could just restore again (from the December 4th backup) the small partition and both would be fine.
    I'll finish reviewing all the suggestions on Time Machine - Troubleshooting and go from there.  Hopefully, the _spotlight indexing simutaniously was the only problem.  It's strange that the indexing hasn't happened since the original restore last week untill I finally got a good clean complete partial Time Machine backup.  Why would the first Time Machine backup trigger indexing again?
    For now, I'm going to exclude the Main Partition again, and let another good backup run.  And try your suggestions.  (And wait till mds, mdworker, etc. to finish!)
    I have the logs of the first two sucsessful backups and the last two failed backups from the last 3 hours, if that would help.?

  • How to call methods from within run()

    Seems like this must be a common question, but I cannot for the life of me, find the appropriate topic. So apologies ahead of time if this is a repeat.
    I have code like the following:
    public class MainClass implements Runnable {
    public static void main(String args[]) {
    Thread t = new Thread(new MainClass());
    t.start();
    public void run() {
    if (condition)
    doSomethingIntensive();
    else
    doSomethingElseIntensive();
    System.out.println("I want this to print ONLY AFTER the method call finishes, but I'm printed before either 'Intensive' method call completes.");
    private void doSomethingIntensive() {
    System.out.println("I'm never printed because run() ends before execution gets here.");
    return;
    private void doSomethingElseIntensive() {
    System.out.println("I'm never printed because run() ends before execution gets here.");
    return;
    }Question: how do you call methods from within run() and still have it be sequential execution? It seems that a method call within run() creates a new thread just for the method. BUT, this isn't true, because the Thread.currentThread().getName() names are the same instead run() and the "intensive" methods. So, it's not like I can pause one until the method completes because they're the same thread! (I've tried this.)
    So, moral of the story, is there no breaking down a thread's execution into methods? Does all your thread code have to be within the run() method, even if it's 1000 lines? Seems like this wouldn't be the case, but can't get it to work otherwise.
    Thanks all!!!

    I (think I) understand the basics.. what I'm confused
    about is whether the methods are synced on the class
    type or a class instance?The short answer is; the instance for non-static methods, and the class for static methods, although it would be more accurate to say against the instance of the Class for static methods.
    The locking associated with the "sychronized" keyword is all based around an entity called a "monitor". Whenever a thread wants to enter a synchronized method or block, if it doesn't already "own" the monitor, it will try to take it. If the monitor is owned by another thread, then the current thread will block until the other thread releases the monitor. Once the synchronized block is complete, the monitor is released by the thread that owns it.
    So your question boils down to; where does this monitor come from? Every instance of every Object has a monitor associated with it, and any synchronized method or synchonized block is going to take the monitor associated with the instance. The following:
      synchronized void myMethod() {...is equivalent to:
      void myMethod() {
        synchronized(this) {
      ...Keep in mind, though, that every Class has an instance too. You can call "this.getClass()" to get that instance, or you can get the instance for a specific class, say String, with "String.class". Whenever you declare a static method as synchronized, or put a synchronized block inside a static method, the monitor taken will be the one associated with the instance of the class in which the method was declared. In other words this:
      public class Foo {
        synchronized static void myMethod() {...is equivalent to:
      public class Foo{
        static void myMethod() {
          synchronized(Foo.class) {...The problem here is that the instance of the Foo class is being locked. If we declare a subclass of Foo, and then declare a synchronized static method in the subclass, it will lock on the subclass and not on Foo. This is OK, but you have to be aware of it. If you try to declare a static resource of some sort inside Foo, it's best to make it private instead of protected, because subclasses can't really lock on the parent class (well, at least, not without doing something ugly like "synchronized(Foo.class)", which isn't terribly maintainable).
    Doing something like "synchronized(this.getClass())" is a really bad idea. Each subclass is going to take a different monitor, so you can have as many threads in your synchronized block as you have subclasses, and I can't think of a time I'd want that.
    There's also another, equivalent aproach you can take, if this makes more sense to you:
      static final Object lock = new Object();
      void myMethod() {
        synchronized(lock) {
          // Stuff in here is synchronized against the lock's monitor
      }This will take the monitor of the instance referenced by "lock". Since lock is a static variable, only one thread at a time will be able to get into myMethod(), even if the threads are calling into different instances.

  • Calling stored procedure from session bean method

    I have a situation like this :
    I have one method on a stateless session bean (and I mark this method as container managed transaction). For database related stuff, I am not using entity beans, I am using my own layer of OR mapping. This method does a lot of stuff and it involves many trips to the database, as a result of which the performance is very poor. I have identified certain pieces of functionality from this method which I think can be moved to stored procedures, while some of the functionality can still remain in the session bean method. So my scenario is like this :
    session bean method start
    store some data in tables(using my OR layer)
    call the stored procedure
    session bean method end
    My question is :
    Will the data that I am storing in tables from within the session bean method, be available to the code executing inside stored proc.
    secondly, how do I sync the transcation which is being initiated by the container with the transaction under which the stored proc is executing or is it that the stored procedure code will also be executing under the container managed transcation.
    Thanks
    Vimal

    Hi Vimal,
    Will the data that I am storing in tables from within
    the session bean method, be available to the code
    executing inside stored proc.There's only one way to find out (isn't there?)
    secondly, how do I sync the transcation which is
    being initiated by the container with the transaction
    under which the stored proc is executing or is it
    that the stored procedure code will also be executing
    under the container managed transcation.Again, why not just "suck it and see!"
    [Or is there some reason why you can't?]
    As I interpret the EJB specification, if the transaction attribute for your session bean method is such that it starts a transaction, then that transaction will be terminated when the method completes -- and every operation that occurs within the framework of that method will be in the one transaction.
    In other words, your database stored procedure should execute within the same transaction as your O/R mapping layer.
    However, how OC4J behaves may not exactly follow what is written in the (EJB) specification. Hence I repeat, "try it and see for yourself".
    Put it this way: as far as I know, the only way that your stored procedure would NOT see the changes made by your O/R mapping layer is if they both executed in separate transactions and the O/R mapping layer did not commit its changes before the stored procedure began its execution.
    Hope this has helped.
    Good Luck,
    Avi.

  • Passing paramaters to a method

    I am passing objects to another method.
    I do some changes to them and expect the changed objects to be available in the calling method ( since they are supposedely passed by reference) when the execution is returned to it. However, I don't get the changed objects but rather the old ones, before the method execution.
    Can someone explain?
    Thanks,
    Boris.

    This is an extremely common question. A search through this forum would be very useful to you.
    Java does not pass-by-reference in the same way C/C++ do. When you pass an object to a method, you can change the contents of the object using its methods and see the changes after the method completes in the calling method. In this way Java is similar to C/C++.
    However, you cannot change an object to equal another object or a new object inside a method and expect the changes to be visible after the method completes in the calling method.
    Here is an example.
    This will show changes and the line "String" would be printed.
      StringBuffer sb = new StringBuffer();
      method(sb);
      System.out.println(sb);
      public void method(StringBuffer buf) {
        buf.append("String");
      }However, this would not show changes and the line "Old String would be printed:
      String string = "Old String";
      method(string);
      System.out.println(string);
      public void method(String string) {
        string = "New String";
        // string.concat("New String) would also fail to work

  • Returning Internal Table as Returning Parameter of Method (by Value).

    When you return an internal table as the returning parameter of a method, it is passed by value.  I understand the concept of passing by value vs. passing by reference, but exactly what this means in this case is ambiguous.
    1)  It could mean that the entire table, including data, is copied from the local table in the method into the parameter provided by the calling code.
    2)  Alternatively, it could mean that only the pointer to the table is passed by value and the data is not literally copied from one place in memory to another.  This would <b>not</b> be the same as passing by reference.  For instance, I believe this is how object references are passed by value.
    I want to know how it works, so that I know if there is an efficiency problem with returning a huge table.  The returning parameter is wonderful for getter methods, and I prefer to use it over exporting parameters, but I have some concern about passing tables as returning parameters since I don't know how this works.
    Can anyone either explain this, or at least make it clear to me whether or not there is an efficiency issue?
    Thanks, in advance,
    -Chris

    Thanks to those who tried to help me with this question, but I finally had to just figure it out on my own.  I just realized today that there is a way to find the answer using the debugger's <i>Go To->Status Display->Memory Use</i> option.  This shows how variables are stored in memory.
    The answer:
    First of all, if you set one internal table equal to another like:
      i_tab1 = i_tab2.
    or like:
      i_tab1[] = i_tab2[].
    both will simply set <i>i_tab1</i> to point to the same memory that <i>i_tab2</i> is using.  It does <b>not</b> make a copy.  Now, if you attempt to change <i>i_tab1</i>, with an <i>append</i> statement for instance, a copy of <i>i_tab2</i>'s memory is made <b>then</b>!  The requested change to <i>i_tab1</i> is then applied to the copied data.  <b>AHA!!!</b>  This means that even if you think you are copying a table, you are not really doing it until it becomes necessary due to a divergence in values.
    I specifically tested a returning parameter to see how memory is handled, and it is basically just like an '<i>=</i>' statment.  No copy of the data is performed at first.  The memory that is allocated for the local variable in the method is simply pointed to by the variable used in the calling code to recieve that value.
    What if you then change the value in the calling code after the method has finished executing?  The answer depends on the situation.  If the value that you returned from the method is still being pointed to by another variable somewhere, then a copy is made when you attempt to change the returned table in the calling code, but if there is no longer another variable pointing to this memory, you can change the table in the calling program all you want without causing a copy in memory.
    For instance, if you have a getter method that returns the value of an attribute, at first no copy will be made, but when you try to change the table in your calling code, a copy will be made then.  However, if you just fill a local table in your getter method and return that table, there will never be a copy made, because the local variable that originally pointed to that memory expired when the method completed.  That means that after the method completes, the only variable pointing to the allocated memory is the one in the calling code that recieved the returning value.
    This is fantastic!!  This behaives in a way that seems to provide maximum efficiency in most cases.  Also, the table copies are <b>never</b> a waste, since they only happen upon changing of one of the table variables that point to the common memory, and in this case you would <b>want</b> to make a copy to avoid corrupting the other variable.
    Also, even if you did return your table as an exporting parameter by reference, you would not gain any significant efficiency.  There would still be no table copy if you don't change the returned table.  Also, if you did change the returned table, you <b>would</b> still produce a table copy if there was another variable, like an attribute, still pointing to the memory that you set your exporting paramter from before.
    The only situation that I can see resulting in a needless efficiency problem is if someone used a getter method to return the value of a table attribute, then changed the returned table in the calling program, and then used a setter method to set the whole table attribute equal to the changed table.  This would be a waste, so maybe this should be accomplished in another way.
    In conclusion, there is essentially no reason to hesitate returning a whole internal table as a returning parameter from a method call, even though it is pass by value.
    Kudos to the ABAP development team for their good design!

  • Datacorruption and static methods

    public static void myMethod( String Argument)
         int i = 0 ;
    What are the chances of data corruption in this static method?
    IF there are chances of data corruption, am I corrupt in saying that chances of data corruption for argument and Variable i are same?
    Where is function state stored in static method stored? What will happen to this if one thread pre-empts other?
    public class a
         int j;
         public static void myMethod( String Argument)
              int i = 0 ;
    How is integer j different from integer i? Where will JVM keep these variables ?

    What are the chances of data corruption in this static
    method? None. As long as this static method only acts on local variables (variables declared inside the method) each call to the method is completely separate from any other call.
    Where is function state stored in static method
    stored? What will happen to this if one thread
    pre-empts other?I'm not sure what you mean by 'function state' but static methods are not associated with an Object, though they can modify and depend on the state of static (class) varaivbles.
    How is integer j different from integer i? Where will
    JVM keep these variables ? j is a member varaible. It is associated wth the instance of the class. i is a local variable and is created at the beginning of a method call and destroyed (eventually) after the method completes.

  • Method local Inner class

    Why method local class can access only the final varaible of the method?
    I found somewhere that this is because the non-final local variables go out of scope after method completion, but i wonder final local variables also reside on the stack.
    class MyOuter2 {
    private String x = "Outer2";
    void doStuff() {
    String z = "local variable";
    class MyInner {
    public void seeOuter() {
    System.out.println("Outer x is " + x);
    System.out.println("Local variable z is " + z); // Won't Compile!
    } // close inner class method
    } // close inner class definition
    } // close outer class method doStuff()
    }

    pxNet wrote:
    and so you are now saying it accesses the original variable, not a copy of it?No, I'm not saying that at all; see reply #1. The situation is quite the opposite, the inner class accesses a copy of the variable. Direct access to the local variable is most definitely not allowed. But that doesn't have anything to do with parameter-passing semantics.
    I'll try to clarify with another demonstration of the problem. Assume that direct access to non-final local variables was actually allowed, and that the following example would compile (it won't, of course): class Outer {
        Inner method() {
            Object o = "foo";
            return new Inner() {
                public void modifyLocalVariable() {
                    o = "bar";
        interface Inner {
            void modifyLocalVariable();
        public static void main(String[] args) {
            Inner inner = new Outer().method();
            inner.modifyLocalVariable(); // what local variable is this modifying?
                                         // the local variable in method() has gone
                                         // out of scope!
    }Because of the way anonymous inner and local classes are implemented, they get a copy of the local variables (per the JLS). Mind you, there isn't any parameter passing going on at all in this example.
    ~

  • Class call a method

    Hi,
    If you have numerous methods in a class, can you just call them like so:
    // in the .fla file
    var john:Person = new Person(63,150); // creates a new person named john 63" and 150lbs.
    john.weight(180); // changes johns weight to 180lbs.
    // in the .as file
    package {
        import flash.display.MovieClip;
        public class Person extends MovieClip {
            public var _perHeight:Number;
            public var _weight:Number;
          public function Person(perHeight:Number, weight:Number) {
                _perHeight=perHeight;
                _weight=weight;
                this.perHeight=_perHeight;
                this.weight=_weight;
            public function changeWeight(newWeight) {
                this.weight=newWeight;
    I must be calling the method completely wrong? I get this error:
    1061: Call to a possibly undefined method weight through a reference with static type Person.

    That is because the method is called "changeWeight" and you are using "weight."
    But what you really want is probably not a method but rather a getter/setter that acts like a property -- or maybe you just want a property.
    So in your class you would have this:
    package {
        import flash.display.MovieClip;
        public class Person extends MovieClip {
            private var _perHeight:Number;
            private var _weight:Number;
            private var _age:Number;
            public function Person(perHeight:Number, weight:Number) {
                _perHeight=perHeight;
                _weight=weight;
            public function set weight(num:Number):void{
                _weight=num;
           public function get weight():Number{
              return _weight;
    Then in your code (after creating a person instance):
    john.weight=180;// changes john's weight to 180.
    The cool thing about getters and setters is that they act just like a property when you use them, but they allow for a whole function call at the other end and can do various things based on the inputs.
    Also variable that start with an underscore are usually private variables. So in this case _weight, _age, and _perHeight would be private -- you couldn't access them directly through the john instance for example. And you would have appropriate getters and setters for them. For example you might make an age setter that didn't allow the number to be set as smaller than the current value or something.

  • Which method of clustering  are aplied in BW Data MininguFF1F

    Come to light,a lot of methods of clustering in stats, such as single linkage method,complete linkage,median method,centroid hierarchical method,ward's minimum variance method.
    Then,which one  clustering method in sap bw?

    Tuffy,
    With respect to the sales quotation, this type of business requirement is normally addressed in SD; you can easily configure a quotation doc such that it does not pass requirements to MRP.
    Assuming order type QT and Item category AGN or AGNN (VOV4), standard allowable Schedule line categories are typically  BN or BP.(VOV5).  BN is not relevant for either ATP nor MRP (OVZ8). You can remove BP from the quotation item categories in VOV5, at which time your QT order would always invoke BN, and never be relevant for MRP. Alternatively, you could make BP not relevant for MRP in OVZ8.  The choice would depend upon other configurations and your other business requirements..
    I would think you would want to use standard functionality in lieu of an enhancement.  Speak to your local SD expert before embarking upon BADI programming.
    Best Regards,
    DB49

  • Plz help!! idempotent methods stateful session beans? (failover)

              plz help!! idempotent methods stateful session beans? (failover)
              Hi there,
              Im trying to failover my shopping cart implemented using stateful ejb, the replication
              is working but the failover is not (Object not found exception....).
              By design is hard to think on an stateful ejb using idempotent methods, but after
              checking the documentation in detail im completely confused, so im starting to
              wonder if i should use idempotent methods or manual retry in case one server is
              down.
              Plz take a loo at these explanations about faiolver in the WLS edocs.
              "....With clustered objects, automatic failover generally occurs only in cases
              where the object is idempotent.....Because of this, replica-aware stubs will not,
              by default, attempt to retry a method that fails after the request is sent but
              before it returns. This behavior can be overridden by marking a service idempotent..."
              BUT
              "By default, a stateful session bean's Home stub provides load balancing and failover
              for its method invocations to any clustered server where the bean is deployed...."
              So is possible to achieve automatic failover (not only load balancing) for stateful
              ejb without having to worry about state-changes or manual retry. (i know the retry
              is requiered if the server crashed just before finishing a transaction but this
              is not what im talking about).
              Any help will be highly appreciated
              Alan
              

              Ryan,
              Yes, im deploying using In-memory replication and clusterable elements, when try
              to invoke the method (after one of the nodes is down) i recieve an "java.rmi.NoSuchObjectException:
              Bean has been deleted".
              I believe all this could be related to some sort of issue with JNDI Lookup in
              the cluster, but haavent been able to get a clue to make it work....(almost desesperate
              by now)
              Alan
              "ryan upton" <[email protected]> wrote:
              >Alan,
              >
              >If the state isn't maintained during failover I would suspect a
              >configuration error. Have you set the <replication-type> element within
              ><stateful-session-clustering> tag in the bean's deployment descriptor?
              >
              >"Alan" <[email protected]> wrote in message
              >news:40e17cf7$1@mktnews1...
              >>
              >> Ryan,
              >>
              >>
              >> Maybe i didnt explain myself, in the scenario im dealing with I KNOW
              >the
              >method
              >> finished succesfully (example, the user succesfully added an item to
              >a
              >cart).
              >>
              >>
              >> Just after that one of the nodes goes down, and the user decides to
              >add a
              >new
              >> item (new invocation , not a retry of failed one) on the same session.
              >>
              >> This is the case in which failover should work automatically as you
              >say,
              >meaning
              >> the new method invokation should be able to retrieve the session state
              >info from
              >> the replica and switch the primary.....Well, this is the part wich
              >isnt
              >working
              >> :( as i understand it should transparently
              >>
              >> I believe could be a config issue , but have no way to make it work.
              >>
              >> Regards,
              >>
              >> Alan
              >> "ryan upton" <[email protected]> wrote:
              >> >
              >> >"Alan" <[email protected]> wrote in message
              >news:40e06296@mktnews1...
              >> >>
              >> >> Ryan,
              >> >>
              >> >> Thanks for clearing the both conditions a bit more, in this case
              >my
              >> >issue
              >> >has
              >> >> to do with the scenario #1 in which subsequent calls (invocations)
              >> >go to a
              >> >node
              >> >> which isnt avaliable(down), do you have any idea of in what conditions
              >> >the
              >> >"automnatic"
              >> >> failover would fail??? (meaning why the stub would try to dispatch
              >> >a call
              >> >to the
              >> >> same previous node)
              >> >>
              >> >> Thanks for the help again
              >> >>
              >> >
              >> >Subsequent calls won't go to a node that's down. That's the whole
              >> >point
              >> >;-). Failover is always automatic, what you are getting confused
              >on
              >> >is
              >> >automatic method re-execution upon failover which happens if the method
              >> >has
              >> >been marked as idempotent. The logic is this: if I failover to an
              >EJB
              >> >that
              >> >I know is still alive, I can't safely call the same method again.
              > Why?
              >> >Because I don't know how much of the method completed the last time
              >before
              >> >the previous bean's failure. So if the bean can yield multiple results
              >> >from
              >> >multiple invocations I had better play it safe and not re-execute
              >the
              >> >method
              >> >on the bean I failed over to (unless it's idempotent because in that
              >> >case it
              >> >doesn't matter how many times I call it, it always does the same thing).
              >> > In
              >> >scenario #1 and #2 failover is automatic and all new calls are executed
              >> >against the bean the client failed over to, but only idempotent methods
              >> >are
              >> >re-executed.
              >> >
              >> >
              >>
              >
              >
              

Maybe you are looking for

  • Troublesho​oting audio no funnciona

    Spoiler (Resaltar para leer) Hola a todos, les escribo porque el sistema de audio de mi laptop Yoga 3 dejo de funcionar solo se escucha musica cuando conecto los audifonos, alguie sabe como solucionar este problea?

  • 5 iTunes icons on my desk top

    I downloaded the recent upgrade (includes safari, quick time, and an iTunes update). All went well but after restarting my computer I had 2 iTunes icons on my desktop. When trying to open one I received the "This action is only valid for products tha

  • Struggling to figure out reasons behind those "An unexpected error has occurred" messages in SharePoint 2010

    We are in day 5 of using SP 2010 on our 4 server farm. The farm was created by taking our MOSS 2007 databases and attaching to our database. We have had a variety of cases of users encountering the "An unexpected error has occurred". In perhaps 10% o

  • RFSAP_PAPERTYPE command in Sap Script

    There is a command written in the Sap Script for Right fax....which is as shown below <RFSAP_PAPERTYPE: ZHEAD> Now, I understood that it automatically overlays fax onto the specified rightfax form... But can anybody tell me as to where this ZHEAD is

  • Default area codes

    I was wondering if I can set my area code as a default when placing calls? Sounds trivial but I make a lot of business calls and like to copy/paste the number directly into Skype's call box, most do not have the area code attached which is needed unl