Confused about wait()_, notify()

hey everyone,
i have a number of executing objects running on independent threads trying to access a single method in a single object. how best can i do this. i am kinda confused. the questions i as myself are should there be a wait and notify in the method that is being called? or is the wait and notify placed in the threads that are trying to call this method.? how do i do this? also when i call notify does it only notify the threads waitin on that particular lock that the notifying thread has locked?
pleas please help me..

yeah i see that that i did understand....this is what i am trying to do. i have a single method in an object which is basically a queue. i want multiple other thread to line up on this queue. so this is what i have in my code
boolean pleaseWait = false;
public synchronized void getOnLine(Truck t) {
while(pleaseWait) {
try {
wait();
catch(Exception e) {
truckLine.enQ(t);
pleaseWait = false;
notifyAll();
but this does not feel right.....i want to know should the above be done in this method or should it be done in the actual thread object that is trying to get on the line. as
public void run() {
synchronized(this) {
while(toAddress.pleaseWait) {
try {
wait();
catch(Exception e) {
toAddress.getOnLine(this);
notify();

Similar Messages

  • About wait() and notify()

    Hello all,
    I have a small problem.Before explaining the problem as such,ill give u a breif description of what i am trying to do
    I have two layers.The upper layer is sender and the lower one is the reciever.Now ,there's only one reciever thread and a number of sending threads.So when one sender sends something...the reciever will start processing with the data.
    In the mean time ,if another sender thread wants to send something to the reciever thread, then it must wait until the reciever enters wait state after it's current processing.
    So the reciever should notify the sender thread which is in wait state...
    My probelm is the sender thread if enters in to wait state once...I'm not able to notify it again when the reciever thread is ready for it.
    Hope some one among u can help me out
    thanking u in advance
    regards
    anees

    you could make the method that does the processing in the receiver, synchronized. that way, the jvm will take care of your requirement.
    if you have to use the wait- notify scheme, then try using notifyAll() instead of notify()

  • Wait and notify

    I have a main that calls a drawing window. The user draws in the window and clicks a button when finished drawing. Then main then gets this image. I don't know how to call the getImage in the main ONLY after the user has clicked the button in the draw window, however. I've heard about wait and notify commands, but I don't know how to use them. Can anyone help me? Thanks.

    Oh my... I'm not a java superstar. I'll post my code and maybe someone can help me. I tried running wait, but it says not thread owner or something weird.
    Main:
    public static void main (String [] args) throws IOException, InterruptedException, AWTException
            Image image = null;
            PaintArea pa = new PaintArea ();
            pa.loadArea (pa);
            //After screen capture
            image = pa.getImage ();}PaintArea:
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    class PaintArea extends Frame
        static int x, y;
        static Image image;
        Canvas canvas = null;
        PaintArea ()
            setSize (110, 160);
            setVisible (true);
            addWindowListener (new WindowAdapter ()
                public void windowClosing (WindowEvent e)
                    hide ();
        public void loadArea (PaintArea pa) throws InterruptedException
            Button button = new Button ("Save");
            Canvas drawArea = new Canvas ();
            drawArea.setSize (100, 100);
            canvas = drawArea;
            pa.setLayout (new BorderLayout ());
            pa.add (drawArea, BorderLayout.CENTER);
            pa.add (button, BorderLayout.SOUTH);
            pa.show ();
            Graphics g = drawArea.getGraphics ();
            final Graphics g2 = g;
            final PaintArea pa2 = pa;
            button.addActionListener (new ActionListener ()
                public void actionPerformed (ActionEvent ae)
                    try
                                          image = saveScreen (pa2);
                    catch (AWTException e)
                        System.err.println (e);
                        System.exit (1);
                    catch (InterruptedException ie)
                        System.err.println (ie);
                        System.exit (1);
            drawArea.addMouseListener (new MouseAdapter ()
                public void mousePressed (MouseEvent me)
                    x = me.getX ();
                    y = me.getY ();
                    g2.fillOval (x - 5, y - 5, 10, 10);
            drawArea.addMouseMotionListener (new MouseMotionAdapter ()
                public void mouseDragged (MouseEvent me)
                    x = me.getX ();
                    y = me.getY ();
                    g2.fillOval (x - 5, y - 5, 10, 10);
        public Image saveScreen (PaintArea pa) throws AWTException
            Image image = null;
            try
                image = createImage (new Robot ().createScreenCapture (pa.getDrawArea ().getBounds ()).getSource ());
            catch (NullPointerException npe)
                System.err.println (npe);
                System.exit (1);
            return image;
        public Picture getImage ()
            return image;
        public Canvas getDrawArea ()
            return canvas;
    }Could someone please run that and try to make the pa.getImage() in the main happen only after the button in Paint Area is pressed? Thanks!

  • Slightly confused about notify method

    Hi,
    I'm currently studying for the SCJP exam and have 2 questions about the thread notify call.
    (1) Is it possible when a thread owns an object lock, i.e. say in synchronized code, that it can call the notify method on a particular thread. For example, say there are 2 threads, names thread1 and thread2, and thead1 obtains object lock, can it call Thread2.notify()? The reason I'm read conflicting web-pages, saying it isn't possible for 1 thread to notify another thread and it is up to Object to decide which thread to invoke, say must use notifyAll() or notify() call. Is this true?
    (2) Which thread in following code is Thread.sleep() referring to? Is it the main thread that created 2 threads?
    class running extends Thread
         public void run(){
    public class fredFlintStone{     
         public static void main(String[] args) {
              running  thread1 = new running();
              running thread2 = new running();
              thread1.start();
              thread2.start();
              try
              //confused here     
            Thread.sleep(12L);
              catch(InterruptedException e)
    }Cheers!

    its best not to confuse terminology here.
    marktheman wrote:
    I ... have 2 questions about the thread notify call.Thread is an object which has a notify() method. However you should never use it. You should only use notify() on regular objects.
    (1) Is it possible when a thread owns an object lock, A Thread holds a lock, see [http://java.sun.com/javase/6/docs/api/java/lang/Thread.html#holdsLock(java.lang.Object)]
    i.e. say in synchronized code, that it can call the notify method on a particular thread. A thread calls notify() on an object not a given thread. (Unless that object is a thread, but don't do that!)
    For example, say there are 2 threads, names thread1 and thread2, and thead1 obtains object lock, can it call Thread2.notify()?It can, but it would fail as you can only call notify() on an object you hold the lock to.
    The reason I'm read conflicting web-pages, saying it isn't possible for 1 thread to notify another thread It is possible but not in any useful way.
    and it is up to Object to decide which thread to invoke,The Object has no say in the matter, its up to the scheduler in the OS.
    say must use notifyAll() or notify() call. Is this true?no.
    (2) Which thread in following code is Thread.sleep() referring to? The javadoc says "Causes the currently executing thread to sleep". You should always check the documentation for asking that sort of question.

  • [SOLVED] Confused about Mobility Radeon HD 3200

    I've always found hard to find good information about this card - some sources, even, contradict themselves. All what I know is that it is an integrated graphics card and that it features the RS780M chipset. These are some tips I've got from the system logs:
    grep -i r600 /var/log/Xorg.0.log
    [ 23.353] (II) RADEON(0): [DRI2] DRI driver: r600
    [ 23.353] (II) RADEON(0): [DRI2] VDPAU driver: r600
    [ 24.099] (II) AIGLX: Loaded and initialized r600
    dmesg | grep -i radeon
    [ 0.000000] Command line: BOOT_IMAGE=/vmlinuz-linux-hf root=UUID=ab92c2db-22b5-4fcb-a33f-2efe3f3f104c ro radeon.modeset=1 radeon.benchmark=0 radeon.tv=0 radeon.pm=0 init=/usr/lib/systemd/systemd quiet
    [ 0.000000] Kernel command line: BOOT_IMAGE=/vmlinuz-linux-hf root=UUID=ab92c2db-22b5-4fcb-a33f-2efe3f3f104c ro radeon.modeset=1 radeon.benchmark=0 radeon.tv=0 radeon.pm=0 init=/usr/lib/systemd/systemd quiet
    [ 1.463857] [drm] radeon kernel modesetting enabled.
    [ 1.464337] radeon 0000:01:05.0: VRAM: 256M 0x00000000C0000000 - 0x00000000CFFFFFFF (256M used)
    [ 1.464340] radeon 0000:01:05.0: GTT: 512M 0x00000000A0000000 - 0x00000000BFFFFFFF
    [ 1.464779] [drm] radeon: 256M of VRAM memory ready
    [ 1.464781] [drm] radeon: 512M of GTT memory ready.
    [ 1.472494] radeon 0000:01:05.0: WB enabled
    [ 1.472499] radeon 0000:01:05.0: fence driver on ring 0 use gpu addr 0x00000000a0000c00 and cpu addr 0xffff8800374a5c00
    [ 1.472502] radeon 0000:01:05.0: fence driver on ring 3 use gpu addr 0x00000000a0000c0c and cpu addr 0xffff8800374a5c0c
    [ 1.472570] [drm] radeon: irq initialized.
    [ 1.472672] radeon 0000:01:05.0: setting latency timer to 64
    [ 1.504277] [drm] radeon atom DIG backlight initialized
    [ 1.504279] [drm] Radeon Display Connectors
    [ 1.504311] [drm] radeon: power management initialized
    [ 2.344989] fbcon: radeondrmfb (fb0) is primary device
    [ 2.441483] radeon 0000:01:05.0: fb0: radeondrmfb frame buffer device
    [ 2.441486] radeon 0000:01:05.0: registered panic notifier
    [ 2.441502] [drm] Initialized radeon 2.30.0 20080528 for 0000:01:05.0 on minor 0
    I also found good (?) information, or at least a clearly-explained article, here. After reading it, UVD appears as the AMD's counterpart of NVIDIA's VDPAU for video acceleration.
    What I'm not sure about, is:
    -  Does it support video acceleration? I'd like to offload video processing to the GPU, but am not sure if my card and the open-source drivers support it or not. Wikipedia's article about VDPAU states it comes from NVIDIA, but then it says it has an open-source implementation.
    -  What has gallium to do with it? What gallium drivers should I enable in mesa? And what about DRI drivers?
    I configured mesa as follows:
    ./configure --prefix=/usr \
    --sysconfdir=/etc \
    --with-dri-driverdir=/usr/lib/xorg/modules/dri \
    --with-gallium-drivers=r600 \
    --with-dri-drivers=radeon \
    --with-llvm-shared-libs \
    --enable-gallium-llvm \
    --enable-egl \
    --enable-gallium-egl \
    --with-egl-platforms=x11,drm \
    --enable-shared-glapi \
    --enable-gbm \
    --enable-glx-tls \
    --enable-dri \
    --enable-glx \
    --enable-osmesa \
    --enable-texture-float \
    --enable-xa \
    --enable-vdpau
    Not sure if I missed something, though.
    I am very confused about how Linux manages graphics, and what all those layers are for. DRM, DRI, VDPAU, VA-API, gl, gl3, xv, xvmc... it's a mess!
    Thanks in advance.
    Last edited by Kalrish (2013-06-16 17:54:04)

    The feature matrix might help. The easy part to answer is that the 3D driver is split into two parts: DRM which is part of the kernel and DRI which is in userspace and comes from the mesa package.
    Xv is an Xserver extension supported by pretty much all drivers. Found in the DDX (xf86-video-*), it uses features of the card to speed up the display of video (but not decoding). It can either do this by using the "video overlay" or creating a shader.
    Now if you want to use Xv but also offload decoding to the card, you need a video acceleration API. The ones to choose from are XvMC, VA-API, VDAPU in increasing order of feature support. They were developed by Xorg, Intel, Nvidia respectively but anyone is free to implement them. I don't think it's correct to call UVD a counterpart of VDPAU. UVD is a bunch of registers on newer AMD cards. And if you sent bits to those registers in the right way, you can implement VDPAU.
    The other way to implement VDPAU (say if the documentation for UVD registers was not released) is to use gallium. There is a gallium state tracker which can still do it at the expense of being slower. It is a hack whereby you convert video frames to polygon textures and make the OpenGL part of the card think that it's calculating part of a 3D scene when really it's decoding video.

  • Java compiler should check if wait() and notify()

    wait(), notify(), and notifyAll() methods should be called within a critical section, but the Java compiler does not check for this. It is usually during running that an Exception is thrown when the methods was not called within a critical section.
    To me, it seems that the compiler should check and enforce that wait(), notify() and notifyAll() be called within a critical section.

    I think I mis-understood you.
    Yes, you are right to say that because callNotify() was called within a critical section at some time, and may be called from other non-critical sections, so the compiler does not have means to keep trace of the calling stack.
    How about this:
    Because critical sections are always marked by the synchronized keyword, the compiler can actually keep count of the synchronized word and its corresponding braces, then when a wait(), or notify(), or notifyAll() call is made at certain point, the compiler just check for the nested synchronized cunt number, if it is non-zero, it will be syntaxically correct.
    Take the example of your code, I see that the proper point for
    public class Test {
      Object lock = new Object();
      public void lockObject() {
        synchronized (lock) {
          callNotify();                     // here the synchronized brace count is 1, so it is OK!
      private void callNotify() {
        lock.notify();               // here the synchronized brace count is 0,
                                            // but because it is a stand alone function, the compiler
                                            // can deliver warning information.
      public void dumbMethod() {
        callNotify();              // should deliver warning
      public static void main(String[] args) {
        Test t = new Test();
        t.lockObject();
        t.callNotify();                   // but here, the synchronized brace count is 0, so failure!
    }

  • Confusion about Master data text

    Hello all, I am little bit confused about the modelling concept in BI7. My confusion is about the Text table creation and its concepts.
    I got a Flat File data in my PC .Here is the scenario:
    Material Num, Material Name,  Material Description
                1111,       Desk ,               Dining table
    Material Name and Material Description are the Attributes of Materaial Number here. When i created Infoobjects Material Number , Material Name (Attribute). I can see that system created a Text table with Short descripton and Language key selected. I understand that i have to load master data and text separately. My question is How did that "short text exists" box got changed?
    In my case "Material Description" is showing Text data "dining table" correct? do i have to create this material description Infoobject as an attributes of Material Num, and later on load this as Text data to it?
    Could anyone tell me how Text data /table come in to play in this example?  Under data/texts tab i see that "language dependent" and "short description" are checked. why "long text exist" and "med text" are not ticked? AFter clicking this T table i know its empty at this point, but is this table waiting for the data to be loaded from "Material Description" Field? if anyone could clarify this confusion i will really appreciat it..thanks
    DK

    Hi DK,
    When you create a characteristic, by default 'With Master Data' & 'With Text' option would be checked.
    We need to manually un-check this if the characteristic created by us is not master or doesn't have text.
    Also, by default 'Short Text Exists' is checked. Short Text can hold description upto 20 chars,
    Medium Text - 40 Chars & Long Text - 60 Chars. Depending on the length of the maximum possible length of description that could come from our source, we need to check the appropriate Texts.
    And you need not create a separate InfoObject for 'MAterial Description'.
    While loading the texts (using Text Transformation & DTP), you can map the Material Description to '0TXTSH' (InfoObject for Short Text).
    Hope this helps!
    Meera

  • About wait()

    below is my program about searching file;
    public class Searcher implements Runnable{
       private Thread t;
       private boolean wantStop=false;
       private boolean wantPause=false;
       private boolean isPause=false;
       public void startSearch(){
            t.start();
       public synchronized void run() {
                  searchFile(startLocation);
       private synchronized void searchFile(File localDirParam){
           if(wantStop){  //if user want stop searching file
                return;
           if(wantPause){  //if user want pause searching file
               try{
                  t.wait();
                  isPause=true;  //sign thread is pause now
               }catch(InterruptedException e){
                   System.out.println("e is "+e);
           else if(wantPause==false&&isPause){  //if thread is pause now and user want to continue search
               t.notify();
               isPause=false;  //sign thread continue
         Vector dirs=getDirs(localFiles);//get local dir's sub dirs
         if(dirs.size()==0){
                return;
            else{
                for(int i=0;i<dirs.size();i++){
                    File localDir=(File)dirs.elementAt(i);
                    searchFile(localDir);
       }error info is:
    java.lang.IllegalMonitorStateException: current thread not owner
    how to currect my program so that java not show the errror info

    You can only call wait, notify, notifyAll on an object whose monitor you hold. You get a monitor by entering a block that's synced on that object.
    Either:
    1) Change t.wait and t.notify to wait and notify
    OR
    2) Sync on t instead of on this.
    I recommend option #1.

  • Confused about cpu information here can you help plz

    if you look below at this link
    http://www.tigerdirect.com/applications/searchtools/item-details.asp?EdpNo=579850&Sku=CP1-P430008NC&SRCCODE=PRICEGRABBER
    Manufacturer Part No: BX80532PG3000D is right here but now look at this website below
    http://www.pricegrabber.com/search_getprod.php/masterid=779130/search=intel%2520pentium%25204/ut=c723210b9e568565
    the manufaturing number are the same but if you read the info on the first link it says 3.6Ghz and the seconed link says 3.0Ghz now is there a BIG (_*_) Mistake or are the company TigerDirect being too specific causing me to be insane lol huh ? Please help me I am trying to get a 3.2Ghz chip egzactley the same as in link 2 but 3.2Ghz not 3.0Ghz are they out yet?
    Please help Thank You very much :P

    I am so happy that I am an MSI guy here at this lovely forum I mean you all helped me so much and you did not have to but I do apreesheate it a lot from you guys I do know that I will be tossing plenty of money in to this chip but the reason why it so high at tigerdirect is because you are paying for there name brand and there product but I love shoping at there store because they are always polite there over the phone and I always get there best service there so I don't mind paying an extra few hundread dollors for there stuff.
    The reason for tossing so much money into this machine is no im not rich we or shall I say I am avrage I have a good job and still live with my parants so I have no utility bills to pay except insurance for my car every month but other then that I can save up quickley if I manage my money the right way hehe. But anywho I paid for the new from soyo SY-P4i875P Dragon2 Platinum Edition Motherboard capable of 3.02Ghz and will have a 3.00Ghz in it with HT   I bought it from http://www.Outpost.com/ witch I did love there service all around but if you pay by check be prepared to wait for 2 weeks lol god lee don't they know wow to torture there customers hehe so plz use money orders hehe but they sent it airborne express I belive thats what it is called correct me if im wrong. and that was quick hehe and also they make sure the person gets it too by having me sign for the package hehe I love how that works.
    I guess you guys are like havent he heard of paragraphs hehe:) Nope sure havent but since I went all out on video and sound I thought hey you know what why don't I dump this AMD and go for Intel pentium but before this desicion came around I was working on my Shuttle AK31 v3.1 and come to find out I ordered the wrong cpu when after I upgraded my bios to handle the xp2100+ cpu 1.73Ghz Thurobroud and was running the 1900+ 1.60Ghz Palimieo or what ever it was called but find out it would on;y run the paliminio chip so I was like well I don't want to overclock my board and put any stress on the board so I will put that 1900+ back in so I take my computer apart and go to take off the volcano 7+ fan made by thermaltake and requires a screwdriver flathead and a bit of skill in there words be carfull and use our product at your risk...lol
    anyways the scredriver sliped and broke off a micro transister and I was like oh crap and could had cryed for damaging my babie but I belive it was time to move on and that is why it hapened when it did hehe..
    but I called tigerdirect to get back on to the subject and told them what I was confused about and magell was his name I believe and he said yes it was a 3.00Ghz and the HT was what made it clock like a 3.06Ghz processor. So I was like wooo thats a relief and was so happy now I will order all of this below hope yo like my system hehe I know I will.
    http://www.tigerdirect.com/applications/SearchTools/item-details.asp?sku=C13-5100
    http://www.tigerdirect.com/applications/SearchTools/item-details.asp?EdpNo=471762&Sku=T925-1050&CatId=795
    http://www.cyberguys.com/templates/searchdetail.asp?T1=148+0070
    http://www.tigerdirect.com/applications/SearchTools/item-details.asp?EdpNo=579850&Sku=CP1-P430008NC
    Pricie hu I will have over 3 grand in my computer lol thats a lot for my hobby but the games are ausome let me tell ya I can't wait for half live 2 I think to come out and I love war games and sniper games like counter strike the graphics are grate
    Also I heard that intel is making a chip next year called the Xeron or somthin and will be 4.00Ghz with HT and the i874 and i8875 chip sets might not be compatible if they change there chip desighn could this also be true too has any one heard this or not? but I will let you go and give your eyes a rest but I thought I should thank yo both for your help and the link I do apreesheate it a lot and hope that everything runs smooth and fast You think?

  • Confused about Bandwidth Profiler - what's it telling me?

    Hi All,
    I'm confused about the bandwidth profiler. I have two
    different SWF
    files, both are profiled for 56K modem. One file is 253K, 150
    x 260 px,
    599 frames @ 10fr/sec showing a preload of 96 frames (9.6 s),
    frame 1 is
    45K. The other is 197K, 800 x 150 px, 1009 frames @ 12fr/sec
    showing a
    preload of 484 frames (40.3 s), frame 1 is 189K. Why does the
    preload
    for the smaller file take 40.3 sec. while the larger file is
    only 9.6
    sec.? And what does preload mean? It appears to indicate how
    long it
    will take to download frame 1, is that correct? Why is the
    Frame 1 size
    so different between the two? And why does the smaller file
    size have a
    much larger frame 1 size. I just don't see why a smaller file
    should
    take longer to load than a larger file.
    Any help would be appreciated.

    preloaders preload all frames - usually a percentage -
    unfortunately most developers make you wait
    until 100% of the movie (all frames/content) is loaded when,
    if built correctly, only a much smaller
    percentage needs to be loaded before playing. Sounds like one
    of your movies has embedded fonts or
    objects set for export on frame 1 (like components) and they
    all have to loaded first (before frame
    1 actually) because flash doesn't know where in your movie
    they are located.
    Chris Georgenes / mudbubble.com / keyframer.com / Adobe
    Community Expert
    Brett wrote:
    > Hi All,
    >
    > I'm confused about the bandwidth profiler. I have two
    different SWF
    > files, both are profiled for 56K modem. One file is
    253K, 150 x 260 px,
    > 599 frames @ 10fr/sec showing a preload of 96 frames
    (9.6 s), frame 1 is
    > 45K. The other is 197K, 800 x 150 px, 1009 frames @
    12fr/sec showing a
    > preload of 484 frames (40.3 s), frame 1 is 189K. Why
    does the preload
    > for the smaller file take 40.3 sec. while the larger
    file is only 9.6
    > sec.? And what does preload mean? It appears to indicate
    how long it
    > will take to download frame 1, is that correct? Why is
    the Frame 1 size
    > so different between the two? And why does the smaller
    file size have a
    > much larger frame 1 size. I just don't see why a smaller
    file should
    > take longer to load than a larger file.
    >
    > Any help would be appreciated.

  • I am confused about something.  How do I read a book on my MacBook Pro?  I can't find the iBook app anywhere, which is what I use on my iPad.  The book I want to read is in my iTunes but I can't click on it.  My iBook library does not show up in iTunes.

    I am confused about something.  How do I read a book on my MacBook Pro?  I can't find the iBook app anywhere, which is what I use on my iPad.  The book I want to read is in my iTunes but I can't click on it.  Some of my iBooks show up in my iTunes but they are "grayed" out.  The only books that respond in iTunes are audiobooks and that's not what I'm looking for.  Is this a stupid question?

    Nevermind - I answered my own question, which is I CAN"T READ ANY BOOKS I purchased in iBooks on my MacBook Pro.  If I want to read on my mac I have to use Kindle or Nook.  Which means any book I've already purchased through iBooks has to be read on my iPad.  Kind of a drag because there are times when it's more convenient for me to read while I'm sitting with my Mac.

  • Confuse about the injecting entity in EJB 3.0?

    Hi all,
    I have an customersBean which is inherit from customersRemote and my problem is i' am little confuse about injecting the entity(customer).
    Where can you apply the EntityManagerFactory is it outside on EJB or Inside the EJB? means outside EJB is use the web application or java application. i have and example.
    this is inside on EJB...............
    public class CustomersBean implements com.savingsaccount.session.CustomersRemote {
    @PersistenceContext(unitName="SavingAccounts")
    EntityManagerFactory emf;
    EntityManager em;
    /** Creates a new instance of CustomersBean */
    public CustomersBean() {
    public void create(int id, String name, String address, String telno, String mobileno)
    try{
    //This is the entity.
    Customer _customer = new Customer();
    _customer.setId(id);
    _customer.setName(name.toString());
    _customer.setAddress(address.toString());
    _customer.setTelno(telno.toString());
    _customer.setMobileno(mobileno.toString());
    em = emf.createEntityManager();
    em.persist(_customer);
    emf.close();
    }catch(Exception ex){
    throw new EJBException(ex.toString());
    in web application, i'm using the @EJB in customer servlets.
    public class CustomerProcessServlet extends HttpServlet {
    @EJB
    private CustomersRemote customerBean;
    blah blah inject directly coming request field from jsp.
    }

    Hi all,
    I have an customersBean which is inherit from customersRemote and my problem is i' am little confuse about injecting the entity(customer).
    Where can you apply the EntityManagerFactory is it outside on EJB or Inside the EJB? means outside EJB is use the web application or java application. i have and example.
    this is inside on EJB...............
    public class CustomersBean implements com.savingsaccount.session.CustomersRemote {
    @PersistenceContext(unitName="SavingAccounts")
    EntityManagerFactory emf;
    EntityManager em;
    /** Creates a new instance of CustomersBean */
    public CustomersBean() {
    public void create(int id, String name, String address, String telno, String mobileno)
    try{
    //This is the entity.
    Customer _customer = new Customer();
    _customer.setId(id);
    _customer.setName(name.toString());
    _customer.setAddress(address.toString());
    _customer.setTelno(telno.toString());
    _customer.setMobileno(mobileno.toString());
    em = emf.createEntityManager();
    em.persist(_customer);
    emf.close();
    }catch(Exception ex){
    throw new EJBException(ex.toString());
    in web application, i'm using the @EJB in customer servlets.
    public class CustomerProcessServlet extends HttpServlet {
    @EJB
    private CustomersRemote customerBean;
    blah blah inject directly coming request field from jsp.
    }

  • Confused about logical table source

    Hi,
    I'm confused about logical table source(LTS), there are 'General', 'Column Mapping', 'Content' tabs in
    LTS, in General tab ,there are some information,like 'Map to there tables' and 'joins',
    just here, we have created relationships in physical layer and BMM layer, so I would like to ask what's the use of the 'joins' here?

    Hi Alpha,
    Valid query, when you establish a complex join it is always between a logical fact and dimension table.Consider a scenario,
    Example:w_person_dx is an extension table not directly joined to a fact but joins to a dimension w_person_d.
    When you model the person_d tables in BMM, you ll have a single logical table with w_person_d as source.If you have to pull columns from both w_person_d and w_person_dx tables in a report, you add dx table as inner join to persond table in the general tab.Now when you check your physical query, you can see the inner join fired between the two dimensions.
    Rgds,
    Dpka

  • Confused about transaction, checkpoint, normal recovery.

    After reading the documentation pdf, I start getting confused about it's description.
    Rephrased from the paragraph on the transaction pdf:
    "When database records are created, modified, or deleted, the modifications are represented in the BTree's leaf nodes. Beyond leaf node changes, database record modifications can also cause changes to other BTree nodes and structures"
    "if your writes are transaction-protected, then every time a transaction is committed the leaf nodes(and only leaf nodes) modified by that transaction are written to JE logfiles on disk."
    "Normal recovery, then is the process of recreating the entire BTree from the information available in the leaf nodes."
    According to the above description, I have following concerns:
    1. if I open a new environment and db, insert/modify/delete several million records, and without reopen the environment, then normal recovery is not run. That means, so far, the BTree is not complete? Will that affact the query efficiency? Or even worse, will that output incorrect results?
    2. if my above thinking is correct, then every time I finish commiting transactions, I need to let the checkpoint to run in order to recreate the whole BTree. If my above thinking is not correct, then, that means that, I don't need to care about anything, just call transaction.commit(), or db.sync(), and let je to care about all the details.(I hope this is true :>)
    michael.

    http://www.oracle.com/technology/documentation/berkeley-db/je/TransactionGettingStarted/chkpoint.html
    Checkpoints are normally performed by the checkpointer background thread, which is always running. Like all background threads, it is managed using the je.properties file. Currently, the only checkpointer property that you may want to manage is je.checkpointer.bytesInterval. This property identifies how much JE's log files can grow before a checkpoint is run. Its value is specified in bytes. Decreasing this value causes the checkpointer thread to run checkpoints more frequently. This will improve the time that it takes to run recovery, but it also increases the system resources (notably, I/O) required by JE.
    """

  • Confused about extending the Sprite class

    Howdy --
    I'm learning object oriented programming with ActionScript and am confused about the Sprite class and OO in general.
    My understanding is that the Sprite class allows you to group a set of objects together so that you can manipulate all of the objects simultaneously.
    I've been exploring the Open Flash Chart code and notice that the main class extends the Sprite class:
    public class Base extends Sprite {
    What does this enable you to do?
    Also, on a related note, how do I draw, say, a line once I've extended it?
    Without extending Sprite I could write:
    var graphContainer:Sprite = new Sprite();
    var newLine:Graphics = graphContainer.graphics;
    And it would work fine. Once I extend the Sprite class, I'm lost. How do I modify that code so that it still draws a line? I tried:
    var newLine:Graphics = this.graphics;
    My understanding is that since I'm extending the Sprite class, I should still be able to call its graphics method (or property? I have no idea). But, it yells at me, saying "1046: Type was not found or was not a compile-time constant: Graphics.

    Thanks -- that helped get rid of the error, I really appreciate it.
    Alas, I am still confused about the extended Sprite class.
    Here's my code so far. I want to draw an x-axis:
    package charts {
        import flash.display.Sprite;
        import flash.display.Graphics;
        public class Chart extends Sprite {
            // Attributes
            public var chartName:String;
            // Constructor
            public function Chart(width:Number, height:Number) {
                this.width = width;
                this.height = height;
            // Methods
            public function render() {
                drawAxis();
            public function drawAxis() {
                var newLine:Graphics = this.graphics;
                newLine.lineStyle(1, 0x000000);
                newLine.moveTo(0, 100);
                newLine.lineTo(100, 100);
    I instantiate Chart by saying var myChart:Chart = new Chart(); then I say myChart.render(); hoping that it will draw the axis, but nothing happens.
    I know I need the addChild method somewhere in here but I can't figure out where or what the parameter is, which goes back to my confusion regarding the extended Sprite class.
    I'll get this eventually =)

Maybe you are looking for

  • Some tables show up in Internet Explorer and not on Modzilla

    I just noticed that some of the cats on the Our Cats page of my website, www.freedomfarm.net, show up on Internet Explorer, but not on Modzilla FireFox.  They are actually listed as a table on the page with a picture and text.   I will confess that I

  • Motion 2 Corrupting Images

    I am stacking 3 to 6 screen grabs saved as TIFF files. One image is display, it fades out after 30 frames and a new one pops-up in the exact same X/Y location. It looks like animation (it's a application tutortial). Randomly Motion will crop the 5 or

  • PS CC 64 win7 keeps crashing

    Hi all, since I installed PS CC, but was happening with CS6 as well, some time when I switch from background to foreground to work with the brush over a layer PS CC crashes. This is the common error I get: Any ideas? sometime when PS restarts it open

  • Invoice not going in block

    Hi all , I have created an invoice with following parameters Base amount : 100  tax percent is 10 % so idealy teh invoice would be for 110 usd but i creted invoice 120 USD 100 as base and tax amount as 20% invoice dint go for block how do i block inv

  • Can't see website unless private browsing

    Hi, I just transferred a domain name from one host to another and worked on a WordPress website under a temporary URL which had a redirect from the old host until the transfer was complete.  After the DNS changes were made, I was not able to see the