Synchronized method not preventing concurrent access

Hi
I have 3 classes, T (a Runnable), TRunner (instantiates and starts a thread using T), and Sync (with one synchronized method, foo).
The problem is that foo is entered concurrently by different threads at the same time. How so?
T.java:
import java.util.Calendar;
class T implements Runnable
   private String name;
   public T(String name)
     this.name = name;
   public void run()
      Thread.currentThread().setName(name);
      Sync s = new Sync();
      System.out.println(Calendar.getInstance().getTime() + ".....Running " + Thread.currentThread().getName());
      s.foo(name);
}TRunner.java:
class TRunner
   public static void main(String args[])
       T tx = new T("x");
       T ty = new T("y");
       T tz = new T("z");
       Thread t1 = new Thread(tx);
       Thread t2 = new Thread(ty);
       Thread t3 = new Thread(tz);
       t1.start();
       t2.start();
       t3.start();
}Sync.java:
import java.util.Calendar;
class Sync
   public synchronized void foo(String threadname)
          System.out.println(Calendar.getInstance().getTime() + ":" + threadname + "....entering FOO");
          try
               Thread.sleep(5000);
          catch (InterruptedException e)
               System.out.println("interrupted");
          System.out.println(Calendar.getInstance().getTime() + ":" + threadname + "....leaving FOO");
}Console output:
C:\javatemp>java TRunner
Mon Apr 09 15:35:46 CEST 2007.....Running x
Mon Apr 09 15:35:46 CEST 2007:x....entering FOO
Mon Apr 09 15:35:46 CEST 2007.....Running y
Mon Apr 09 15:35:46 CEST 2007:y....entering FOO
Mon Apr 09 15:35:46 CEST 2007.....Running z
Mon Apr 09 15:35:46 CEST 2007:z....entering FOO
Mon Apr 09 15:35:51 CEST 2007:x....leaving FOO
Mon Apr 09 15:35:51 CEST 2007:y....leaving FOO
Mon Apr 09 15:35:51 CEST 2007:z....leaving FOO
C:\javatemp>Thanks in advance.

Only for static methods. For instance methods, the lock >is the object.You are absolutely right.
The Class object is no different from any other object. >"Entire" Class object makes no sense.What I wanted to say is that it's better to synchronize on the object we want to protect from concurrent access rather than on the entire class or instance object.
"Efficiency" is not altered by locking on a Class object vs. >any other object.I studied that it's better to synchronize on the objects we want to protect instead of the entire instance or class object. If one declares a method as synchronized, it means that other threads won't be able to access other synchronized methods for the same object, even if the two weren't in conflict. That was explained as a performance penalty.
>
Or when one or more threads may modify it and one or
more may read it.
Yep, sure.
>
No, they're not.
You are absolutely right. What I wanted to say is that local variables are unique per thread.
>
Local variables are unique per thread, but that's NOT
atomicity.Sorry for any confusion
Message was edited by:
mtedone

Similar Messages

  • Static synchronized methods VS non-static synchronized methods ??

    what is the difference between static synchronized methods and non-static synchronized methods as far as the behavior of the threads is concerned? if a thread is in static synchronized method can another thread access simple (ie. non static) synchronized methods?

    javanewbie80 wrote:
    Great. Thanks. This whole explanation made a lot of sense to me.Cool, glad I was able to help!
    Probably I was just trying to complicate things unnecessarily.It's a classic case of complexity inversion. It seems simpler to say something like "synchronization locks the class" or "...locks the method" than to give my explanation and then extrapolate the implications. Just like the seemingly simpler, but incorrect, "Java passes objects by reference," vs. the correct "Java passes references by value," or Java's seemingly complex I/O vs. other languages' int x = readInt(); or whatever.
    In the seemingly complex case, the primitive construct is simpler, but the higher level construct requires more assembly or derivation of the primitive constructs, making that case seem more complicated.
    Okay, I just re-read that, and it seems like I'm making no sense, but I'll leave it, just in case somebody can get some meaning out of it. :-)

  • Re Time Machine "You do not have appropriate access privileges to save file ".002332b7be8a" warning preventing backups--this may help temporarily

    My TM is often giving me the "You do not have appropriate access privileges to save file “.002332b7be8a” in folder “Time Machine Backups”" message when I go to select my backup drive. I've reviewed past archived discussions on this and, like many other people, gotten completely flummoxed trying to find a permanent solution.  Tried the suggested fixes via Terminal and it didn't help because I couldn't get through the entire process without Terminal telling me it couldn't find a file or drive.  When I can find the time, I'm going to try Tinker Tool to reveal where that numbered file actually is and give it another go.
    In the meantime, for those who are desperate to get their TM working again to get at least one backup done, I can offer people a temporary solution that's worked for me.
    I've found that restarting my iMac somehow resets TM and usually allows it to do at least one of its automatic backups, sometimes several, before it reverts back to failing and producing that same darn warning message.  I only want a backup done once a day, so it's not that inconvenient to go this route.
    There's another even quicker  method (perhaps a little more risky but hasn't been a problem for me yet) that I've been using more recently, and that is to simply unplug the external while the iMac is on (I close system preferences first though, and make sure TM isn't actually doing anything at the time) then plugging it back in and choosing the backup drive again in the TM system preferences window once that drive has shown up again in the Mac's list of devices.  I don't get that warning message when I do this.  It works every time for me and so far it hasn't lost or corrupted any data on the external, despite the warning message you get on Macs when you unplug a USB device without ejecting it first.  However, do this at your own risk--don't flame me if it backfires on you.  If you're of the opinion that it's not wise to unplug the device this way, then fine, go ahead and state such in this thread, but be polite about it.
    Hope this helps anyone who's frantic to make a backup without having to start from square one with a whole new complete initial backup (can take many hours to make one) on a fresh external drive.
    By the way, I've read somewhere that this problem was fixed with Snow Leopard.  Whether that's true is another matter.  I'm not quite ready to update to 10.6 for other reasons, even though I bought it, and I figure some other people are also still using 10.5.8 out of fear and loathing around the unknowns of installing a new OS too, so that's why I thought I'd post this message (couldn't find a discussion around this that was still active and not archived).

    noodlenose wrote:
    My TM is often giving me the "You do not have appropriate access privileges to save file “.002332b7be8a” in folder “Time Machine Backups”" message when I go to select my backup drive.
    Wow, I haven't seen that in a looooong time!
    Tried the suggested fixes via Terminal and it didn't help because I couldn't get through the entire process without Terminal telling me it couldn't find a file or drive.
    Do you mean in #C5 of Time Machine - Troubleshooting?
    When I can find the time, I'm going to try Tinker Tool to reveal where that numbered file actually is and give it another go.
    It should be at the top level of the drive.
    By the way, I've read somewhere that this problem was fixed with Snow Leopard.
    Yes.  I'm not sure if it was 10.6.0 or one of the early updates, but I haven't seen any reports of this in quite a while.

  • ITunes error: The iPhone "iPhone" cannot be synced. You do not have enough access privileges for this operation. is preventing my iPhone from syncing. How do I fix it?

    The iPhone "iPhone" cannot be synced. You do not have enough access privileges for this operation. is preventing my iPhone from syncing. How do I fix it? I have changed permissions until blue in the face. What is going on? Why is this so hard? I just want to sync my phone.
    A little background. My iTunes library is in a shared folder. My Aperture library is on a .DMG in the shared folder with "ignore permissions on this volume" checked. I have added myself with read and write privileges to everything that I can find. What gives? Thanks in advance.

    PC, windows7, iphone4, updated iphone (5.0.1) and itunes (10.5.2.11) software. Started getting "iphone cannot be synced. You do not have enough access privileges for this operation" message.
    Solution I found that worked: Uncheck "Sync photos from Iphone" in Itunes / Devices / Photos tab.

  • Not able to access parent instance variable in outside of methods in child

    Hi,
    I am not getting why i am not able to access parent class instance variable outside the child class intance methods.
    class Parent
         int a;
    class Child extends Parent
         a = 1; // Here i am getting a compilation error that Syntax error on token "a", VariableDeclaratorId expected after this token
         void someMethod()
              a = 1;  // Here i am not getting any compilation error while accessing parent class variable
    }Can any one please let me know exact reason for this and what is the error talks about?
    Thanks,
    Uday
    Edited by: Udaya Shankara Gandhi on Jun 13, 2012 3:30 AM

    You can only put assignments or expressions inside methods, constructors or class initializors, or when declaring a variable.
    It has nothing to the with Child extending Parent.
    class Parent {
        int a = 1;
        { a = 1; }
        public Parent() {
            a = 1;
       public void method() {
           a = 1;
    }

  • Problem in concurrent access of a single method

    Hi,
    I have one servlet named "Controllerservlet.java" and a jsp page "Inward jsp".
    Now from this jsp user enters data which are being passed to controller servlet 's "insertData" method which is a synchronized method then it stores the query result in a variable "query_result" whatever it is ( if it throws exception "duplicate value insertion.... this will be assigned to query_result).
    now when only one user is using then it is working fine.But when two user tried to enter the same data simultaneously then in one sceen it showed error message "Can't insert Duplicate value " and in others's it didn't show anything but inserted data.
    I know that when i think data is being entered simultaneously then it is actually not simultaneously for computer.but according to me it shud have shown in one screen "successfully entered" and in other error message "Duplicate value....".
    this is my servlets code
    private synchronized void insertData(HttpServletRequest req, HttpServletResponse res)
                 String date = req.getParameter("date");
                 String department[] = req.getParameterValues("Department");
                 String main_Building[] = req.getParameterValues("Main_Building");
                 String Other = req.getParameter("Other");
                 String Roll_No = req.getParameter("Roll_No");
                 String Receiver = req.getParameter("Receiver");
                 String subject = req.getParameter("subject");
                  String buttontype = req.getParameter("buttontype");
                 String entrytype = req.getParameter("type");
                 String query="";
                 String query_result="";
                 String source="";
                 String Department="",Main_Building="";
                 if(department!=null && !department[0].equals("Select"))Department=department[0];
                 if(department!=null)
                for (int i=1;i<department.length;i++)
                        Department+=","+department;
    if(!Department.equals("")) source= Department;
    if(main_Building!=null && !main_Building[0].equals("Select"))
    Main_Building=main_Building[0];
    if(main_Building!=null)
    for (int i=1;i<main_Building.length;i++)
    Main_Building+=","+main_Building[i];
    if(!Main_Building.equals(""))
    if(source.length()!=0)
    source+="/"+Main_Building;
    else source = Main_Building;
    if(Other!=null&&Other.length()!=0)
    if(source.length()!=0)
    source+="/"+Other;
    else source = Other;
    Date now = new Date();
    SimpleDateFormat formatter = new SimpleDateFormat(" hh:mm:ss a zzz");
    String user = (String)session.getAttribute("user");
    int srno=1;
    try {
    conn.setAutoCommit(false);
    ResultSet rs = stmt.executeQuery("select max(srno) from incommingletters where deleted = 'F'");
    if (rs.next())srno=rs.getInt(1);
    srno++;
    query= "insert into incommingletters values ("+srno+",'"+date+"','"+source+"','"+Roll_No+"','"+Receiver+"','"+subject+"','"+entrytype+"','F')";
    stmt.executeUpdate(query);
    query="insert into traceuser values ('"+user+"','Insertion','"+now+"','"+formatter.format(now)+"',"+srno+")";
    stmt.executeUpdate(query);
    conn.commit();
    query_result="Entry No. "+srno+" Successfully Saved";
    catch (SQLException e)
    query_result= e.toString();
    try
    conn.rollback();
    catch (SQLException e1)
    out.println(e.toString());
    out.println(e.toString());
         session.setAttribute("query_result",query_result);
         //gotojspPage("/resources/Inward.jsp", req, res);
              try
                   res.sendRedirect(res.encodeRedirectURL("../resources/Inward.jsp"));
              catch (Exception e)
                   out.println(e.toString());
    manish

    hi declangallagher,
    now i am doing the connection in bean it looks like this
    servlet code :
    public class ControllerServlet extends HttpServlet
        PrintWriter out;
        HttpSession session;
        String  name=null;
        String buttontype=null;
        ManipulationOfData md= new ManipulationOfData();
         * Method which intialises the servlet
         * @throws ServletException
        public void init() throws ServletException
             * Method in servlet
             * @param req HttpServletRequest req
             * @param res HttpServletResponse res
             * @throws java.io.IOException
             * @throws ServletException
            public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
                doGet(req, res);
         * Method used in servlet
         * @param req HttpServletRequest req
         * @param res HttpServletResponse res
         * @throws IOException
         * @throws ServletException
        public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
            res.setContentType("text/html");
            out = res.getWriter();
            session = req.getSession(true);
            initialization();
         try
                  trafficController(req, res);
            catch (Exception e)
                out.println(e.toString() + " In traffic controller");
             * Method that controls the traffic in Controllerservlet
             * @param req HttpServletRquest req
             * @param res HttpServletResponse res
             * @throws Exception
            private void trafficController(HttpServletRequest req, HttpServletResponse res) throws Exception
             String submit=null;
            submit= req.getParameter("submit");
            if (submit != null)
                submit = submit.trim();
            if (submit!=null)
                    if (submit.equalsIgnoreCase("submit"))
                             buttontype =  req.getParameter("buttontype");
                               if(buttontype!=null)session.setAttribute("buttontype",buttontype);
                               insertData(req,res);
                   else if (submit.equalsIgnoreCase("Sign in"))
                         removeValiditySession();
                           checkUser(req,res);
                   else if (submit.equalsIgnoreCase("inward"))
                          removeInwardSession();
                       res.sendRedirect(res.encodeRedirectURL("../resources/Inward.jsp"));
                        //gotojspPage("/resources/Inward.jsp", req, res);
                   else if (submit.equalsIgnoreCase("edit"))
                        removeOkSession();
                       session.setAttribute("updation","edit");
                       res.sendRedirect(res.encodeRedirectURL("../resources/serialno.jsp"));
                   else if (submit.equalsIgnoreCase("remove"))
                        removeOkSession();
                       session.setAttribute("updation","delete");
                       res.sendRedirect(res.encodeRedirectURL("../resources/serialno.jsp"));
                    else if (submit.equalsIgnoreCase("Ok"))
                        editDelete(req,res);
                    else if (submit.equalsIgnoreCase("view"))
                           removeShowSession();
                        res.sendRedirect(res.encodeRedirectURL("../resources/viewresult.jsp"));
                             //gotojspPage("/resources/viewresult.jsp", req, res);
                    else if (submit.equalsIgnoreCase("Update"))
                        updateRecord(req,res);
                    else if (submit.equalsIgnoreCase("Delete"))
                        //out.println("manish");
                          deleteRecord(req,res);
                            //gotojspPage("/resources/delete.jsp", req, res);
                    else if (submit.equalsIgnoreCase("Show Data"))
                        removeShowSession();
                           showData(req,res);
                    else if (submit.equalsIgnoreCase("signout"))
                        SignOut();
                      res.sendRedirect(res.encodeRedirectURL("../resources/signout.jsp"));
                    else if (submit.equalsIgnoreCase("home"))
                        res.sendRedirect(res.encodeRedirectURL("../resources/authentication.jsp"));
                    else if (submit.equalsIgnoreCase("back"))
                        removeShowSession();
                        res.sendRedirect(res.encodeRedirectURL("../resources/viewresult.jsp"));
                    else if (submit.equalsIgnoreCase("deleteback"))
                        removeInwardSession();
                        res.sendRedirect(res.encodeRedirectURL("../resources/Inward.jsp"));
                      else
                           out.println("No Target");
        private void checkUser(HttpServletRequest req, HttpServletResponse res)
            try
                Authentication auth = new Authentication();
                String user = req.getParameter("userid");
                user = user.trim();
                String password = req.getParameter("password");
                password = password.trim();
                session.setAttribute("password", password);
                String validity = auth.isValid(user, password);
                session.setAttribute("validity", validity);
                session.setAttribute("user",user);
                if(validity.equals("true"))
                      removeInwardSession();
                    res.sendRedirect(res.encodeRedirectURL("../resources/Inward.jsp"));
                   //gotojspPage("/resources/Inward.jsp", req, res);
                else
                    removeInwardSession();
                    res.sendRedirect(res.encodeRedirectURL("../resources/authentication.jsp"));
            catch (Exception ex)
                out.println(ex.toString());
            private   void insertData(HttpServletRequest req, HttpServletResponse res)
                 String date = req.getParameter("date");
                 String department[] = req.getParameterValues("Department");
                 String main_Building[] = req.getParameterValues("Main_Building");
                 String Other = req.getParameter("Other");
                 String Roll_No = req.getParameter("Roll_No");
                 String Receiver = req.getParameter("Receiver");
                 String subject = req.getParameter("subject");
                  String buttontype = req.getParameter("buttontype");
                 String entrytype = req.getParameter("type");
                 String query="";
                 String query_result="";
                 String source="";
                 String Department="",Main_Building="";
                 if(department!=null && !department[0].equals("Select"))Department=department[0];
                 if(department!=null)
                for (int i=1;i<department.length;i++)
                        Department+=","+department;
    if(!Department.equals("")) source= Department;
    if(main_Building!=null && !main_Building[0].equals("Select"))
    Main_Building=main_Building[0];
    if(main_Building!=null)
    for (int i=1;i<main_Building.length;i++)
    Main_Building+=","+main_Building[i];
    if(!Main_Building.equals(""))
    if(source.length()!=0)
    source+="/"+Main_Building;
    else source = Main_Building;
    if(Other!=null&&Other.length()!=0)
    if(source.length()!=0)
    source+="/"+Other;
    else source = Other;
    String user = (String)session.getAttribute("user");
    query_result=md.InsertData(date,source,Roll_No,Receiver,subject,entrytype,user);
         session.setAttribute("query_result",query_result);
         //gotojspPage("/resources/Inward.jsp", req, res);
              try
                   res.sendRedirect(res.encodeRedirectURL("../resources/Inward.jsp"));
              catch (Exception e)
                   out.println(e.toString());
    private void showData(HttpServletRequest req, HttpServletResponse res)
    String exactdate = req.getParameter("date");
    String srnostr = req.getParameter("srno");
    String fromdate = req.getParameter("from");
    String todate = req.getParameter("to");
    String Roll_No = req.getParameter("Roll_No");
    String Receiver = req.getParameter("Receiver");
    String subject = req.getParameter("subject");
    String Department = req.getParameter("Department");
    String Main_Building = req.getParameter("Main_Building");
    String Other = req.getParameter("Other");
    String entrytype = req.getParameter("type");
    String condition="";
    String buttontxt ="",source="";
    String date;
    // out.println(fromdate);out.println(todate);
    subject = subject.trim();
    if(!Department.equalsIgnoreCase("Select")) source= Department;
    if(!Main_Building.equalsIgnoreCase("Select"))
    if(source.length()!=0)
    source+="/"+Main_Building;
    else source = Main_Building;
    if(Other!=null&&Other.length()!=0)
    if(source.length()!=0)
    source+="/"+Other;
    else source = Other;
    if (exactdate!=null && exactdate.length()!=0) condition = " date = '"+exactdate+"'";
    else if(fromdate!=null &&todate!=null &&fromdate.length()!=0 && todate.length()!=0)
    condition = " date between '"+ fromdate+"' and '"+ todate+"'";
    if(source!=null&&source.length()!=0)
    if(!condition.equals(""))
    condition+=" AND source like '%"+source+"%'";
    else
    condition+=" source like '%"+source+"%'";
    if(Roll_No!=null&&Roll_No.length()!=0)
    if(!condition.equals(""))
    condition+=" AND rollno like '%"+Roll_No+"%'";
    else
    condition+=" rollno like '%"+Roll_No+"%'";
    if(Receiver!=null&&!Receiver.equalsIgnoreCase("Select"))
    if(!condition.equals(""))
    condition+=" AND reciever like '%"+Receiver+"%'";
    else
    condition+=" reciever like '%"+Receiver+"%'";
    if(subject!=null&&subject.length()!=0)
    if(!condition.equals(""))
    condition+=" AND subject like '%"+subject+"%'";
    else
    condition+=" subject like '%"+subject+"%'";
    if(entrytype!=null&&entrytype.length()!=0)
    if(!condition.equals(""))
    condition+=" AND type = '"+entrytype+"'";
    else
    condition+=" type = '"+entrytype+"'";
    if(srnostr!=null&&srnostr.length()!=0)
    int srno = Integer.parseInt(srnostr);
    if(!condition.equals(""))
    condition+=" AND srno = "+srno;
    else
    condition+=" srno = "+srno;
    buttontxt = req.getParameter("buttontxt");
    Vector show_data_vec = md.showData(condition);
    String queryexception= show_data_vec.elementAt(0).toString();
    Vector cols_name_vec = (Vector)show_data_vec.elementAt(1);
    Vector resultset_ob_vec = (Vector)show_data_vec.elementAt(2);
    if(queryexception.equals("Successful"))
    try {
    res.sendRedirect(res.encodeRedirectURL("../resources/result.jsp"));
    catch (IOException e)
    out.println(e.toString());
    else
    try
    res.sendRedirect(res.encodeRedirectURL("../resources/viewresult.jsp"));
              catch (Exception e)
                   out.println(e.toString());
    session.setAttribute("queryexception",queryexception);
    session.setAttribute("buttontxt",buttontxt);
    session.setAttribute("resultset_ob_vec",resultset_ob_vec);
    session.setAttribute("cols_name_vec",cols_name_vec);
    private void updateRecord(HttpServletRequest req, HttpServletResponse res)
    String date = req.getParameter("date");
    String department[] = req.getParameterValues("Department");
    String main_Building[] = req.getParameterValues("Main_Building");
    String Other = req.getParameter("Other");
    String Roll_No = req.getParameter("Roll_No");
    String Receiver = req.getParameter("Receiver");
    String subject = req.getParameter("subject");
         String buttonedit = req.getParameter("buttonedit");
    String entrytype = req.getParameter("type");
    String query="";
    String source="";
    String serialnostr=(String)session.getAttribute("serialno");
    int serialno=Integer.parseInt(serialnostr);
    String Department="",Main_Building="";
    if(department!=null && !department[0].equals("Select"))Department=department[0];
    if(department!=null)
    for (int i=1;i<department.length;i++)
    Department+=","+department[i];
    if(!Department.equals("")) source= Department;
    if(main_Building!=null && !main_Building[0].equals("Select"))
    Main_Building=main_Building[0];
    if(main_Building!=null)
    for (int i=1;i<main_Building.length;i++)
    Main_Building+=","+main_Building[i];
    if(!Main_Building.equals(""))
    if(source.length()!=0)
    source+="/"+Main_Building;
    else source = Main_Building;
    if(Other!=null&&Other.length()!=0)
    if(source.length()!=0)
    source+="/"+Other;
    else source = Other;
    String user = (String)session.getAttribute("user");
    String editqrexception=null;
    ResultsetData rsdata = new ResultsetData();
    editqrexception=md.UpdateData(rsdata,date,source,Roll_No,Receiver,subject,serialno,entrytype,user);
    session.setAttribute("rsdata",rsdata);
    session.setAttribute("buttonedit",buttonedit);
    session.setAttribute("editqrexception",editqrexception);
    try
    res.sendRedirect(res.encodeRedirectURL("../resources/edit.jsp"));
    catch (Exception e)
    out.println(e.toString());
    private void deleteRecord(HttpServletRequest req, HttpServletResponse res)
              String serialnostr = (String) session.getAttribute("serialno");
    int serialno = Integer.parseInt(serialnostr);
              out.println(serialno);
              String deleteqrexception=null,buttondelete=null;
    ResultsetData rsdata = new ResultsetData();
    String user = (String)session.getAttribute("user");
    deleteqrexception=md.DeleteData(rsdata,serialno,user);
              if(!deleteqrexception.equals("Successful"))
    session.setAttribute("rsdata",rsdata);
    session.setAttribute("buttondelete",buttondelete);
    session.setAttribute("deleteqrexception",deleteqrexception);
    try
    res.sendRedirect("../resources/delete.jsp");
    catch (Exception e)
    out.println(e.toString());
    else
    try
    res.sendRedirect(res.encodeRedirectURL("../resources/deletemessage.html"));
    catch (Exception e)
    out.println(e.toString());
    private void editDelete(HttpServletRequest req, HttpServletResponse res)
    String buttonok=null;
    String updation=(String)session.getAttribute("updation");
    String serialnostr = req.getParameter("serialno");
    buttonok = req.getParameter("buttonok");
    session.setAttribute("buttonok",buttonok);
    int rowcount = 0;
    ResultsetData rsdata = new ResultsetData();
    String query_result =null;
    int serialno = Integer.parseInt(serialnostr);
    query_result = md.editDelete(serialno,rsdata);
    session.setAttribute("serialno",serialnostr);
    session.setAttribute("rsdata",rsdata);
    if(query_result.equals("Successful"))
    if (updation!=null)
    if(updation.equals("edit"))
    try
    removeEditSession();
    res.sendRedirect(res.encodeRedirectURL("../resources/edit.jsp"));
    catch (IOException e)
    out.println(e.toString());
    else if (updation.equals("delete"))
    try {
    removeDeleteSession();
    res.sendRedirect(res.encodeRedirectURL("../resources/delete.jsp"));
    catch (IOException e)
    out.println(e.toString());
    else
    try
    res.sendRedirect(res.encodeRedirectURL("../resources/serialno.jsp"));
              catch (Exception e)
                   out.println(e.toString());
    private void initialization()
    Vector initial_vec = new Vector();
    Vector departments_vec = new Vector();
    Vector mainbuild_vec = new Vector();
    Vector receiver_vec = new Vector();
    initial_vec = md.Initialization();
    departments_vec = (Vector)initial_vec.elementAt(0);
    mainbuild_vec = (Vector)initial_vec.elementAt(1);
    receiver_vec = (Vector)initial_vec.elementAt(2);
    session.setAttribute("departments_vec",departments_vec);
    session.setAttribute("mainbuild_vec",mainbuild_vec);
    session.setAttribute("receiver_vec",receiver_vec);
    private void removeInwardSession()
              String serialno ="";
              String buttontype = (String)session.getAttribute("buttontype");
    serialno = (String) session.getAttribute("serialno");
              if(serialno!=null)
                        serialno=null;
                        session.setAttribute("serialno",serialno);
              if(buttontype!=null)
                        buttontype=null;
                        session.setAttribute("buttontype",buttontype);
    private void removeShowSession()
              String buttontxt ="";String queryexception ="";
              buttontxt = (String) session.getAttribute("buttontxt");
              if(buttontxt!=null)
                        buttontxt=null;
                        session.setAttribute("buttontxt",buttontxt);
    queryexception = (String) session.getAttribute("buttontxt");
              if(queryexception!=null)
                        queryexception=null;
                        session.setAttribute("queryexception",queryexception);
    private void removeEditSession()
              String buttonedit ="";
              buttonedit = (String) session.getAttribute("buttonedit");
              if(buttonedit!=null)
                        buttonedit=null;
                        session.setAttribute("buttonedit",buttonedit);
    private void removeDeleteSession()
              String buttondelete ="";
              buttondelete = (String) session.getAttribute("buttondelete");
              if(buttondelete!=null)
                        buttondelete=null;
                        session.setAttribute("buttondelete",buttondelete);
    private void removeOkSession()
              String buttonok ="";
              buttonok = (String) session.getAttribute("buttonok");
              if(buttonok!=null)
                        buttonok=null;
                        session.setAttribute("buttonok",buttonok);
    private void removeValiditySession()
              String validity ="";
              validity = (String) session.getAttribute("validity");
              if(validity!=null)
                        validity=null;
                        session.setAttribute("validity",validity);
    private void SignOut()
    removeValiditySession();
    public void destroy()
    try
    ConnectionPool.freeCon(conn);
    removeValiditySession();
    catch (Exception exp)
    out.println(exp.toString());
    i know its very lengthy so concentrate on insertData method and doget only
    and here is the bean
    public class ManipulationOfData
            String url="jdbc:postgresql://10.99.13.203/dispatch";
            String driver="org.postgresql.Driver";
            String username="manish";
            String password="manish";
            Connection conn=null;
            Statement stmt =null;
           String valid="false";
        public void getConnection()
          try
               Class.forName(driver);
               conn = DriverManager.getConnection(url,username,password);
               stmt= conn.createStatement();
            catch(Exception e)
                valid=e.toString();
        public void closeConnection()
          try
               stmt.close();
               conn.close();
            catch(Exception e)
                valid=e.toString();
        public synchronized String InsertData(String date,String source,String Roll_No,String Receiver,String subject,String entrytype,String user)
            getConnection();
            int srno=1;
            String query_result="";
            Date now = new Date();
            SimpleDateFormat formatter = new SimpleDateFormat(" hh:mm:ss a zzz");
                try {
                        conn.setAutoCommit(false);
                        ResultSet rs = stmt.executeQuery("select max(srno) from incommingletters where deleted = 'F'");
                        if (rs.next())srno=rs.getInt(1);
                        srno++;
                        String query= "insert into incommingletters values ("+srno+",'"+date+"','"+source+"','"+Roll_No+"','"+Receiver+"','"+subject+"','"+entrytype+"','F')";
                            stmt.executeUpdate(query);
                            query="insert into traceuser values ('"+user+"','Insertion','"+now+"','"+formatter.format(now)+"',"+srno+")";
                            stmt.executeUpdate(query);
                            conn.commit();
                         query_result="Entry No. "+srno+" Successfully Saved";
                catch (SQLException e)
                        query_result= e.toString();
                        try
                            conn.rollback();
                        catch (SQLException e1)
                            query_result=e.toString();
                      query_result=e.toString();
            closeConnection();
        return query_result;
        public synchronized String UpdateData(ResultsetData rsdata,String date,String source,String Roll_No,String Receiver,String subject,int serialno,String entrytype,String user)
            getConnection();
            String query_result="";
            Date now = new Date();
            SimpleDateFormat formatter = new SimpleDateFormat(" hh:mm:ss a zzz");
            try {
                    conn.setAutoCommit(false);
                    String query= "update incommingletters set date = '"+date+"',type = '"+entrytype+"',source = '"+source+"',rollno = '"+Roll_No+"',"+
                            "reciever = '"+Receiver+"',subject = '"+subject+"' where srno ="+serialno +" and deleted = 'F'";
                    stmt.executeUpdate(query);
                    query="insert into traceuser values ('"+user+"','Updation','"+now+"','"+formatter.format(now)+"',"+serialno+")";
                    stmt.executeUpdate(query);
                   conn.commit();
                   ResultSet rs = stmt.executeQuery("select * from incommingletters where srno ="+serialno+
                           " and deleted = 'F'");
                   rsdata =  putResClass(rs,rsdata);
                    //conn.close();
                    //ConnectionPool.freeCon(conn);
                    query_result="Successfully Updated";
                catch (SQLException e)
                    try
                        conn.rollback();
                        //conn.close();
                        //  ConnectionPool.freeCon(conn);
                    } catch (SQLException e1) {
                        query_result=e.toString();
                    query_result=e.toString();
            closeConnection();
         return query_result;
        public synchronized String DeleteData(ResultsetData rsdata,int serialno,String user)
            getConnection();
            Date now = new Date();
            SimpleDateFormat formatter = new SimpleDateFormat(" hh:mm:ss a zzz");
            String query_result="";
            try {
                    conn.setAutoCommit(false);
                    stmt.executeUpdate("update incommingletters set deleted ='T' where srno ="+serialno);
                    String query="insert into traceuser values ('"+user+"','Deletion','"+now+"','"+formatter.format(now)+"',"+serialno+")";
                    stmt.executeUpdate(query);
                    conn.commit();
                    query_result = "Successful";
            catch (SQLException e)
                query_result=e.toString();
                try {
                        conn.rollback();
                        ResultSet rs = stmt.executeQuery("select * from incommingletters where srno ="+serialno+" and deleted='F'");
                        rsdata =  putResClass(rs,rsdata);
                        // conn.close();
                        //ConnectionPool.freeCon(conn);
                catch (SQLException e1)
                        query_result=e1.toString();
             closeConnection();
           return query_result;
       public Vector showData(String condition)
           getConnection();
           String query="",query_result="";
           int rowcount=0;
           Vector show_data = new Vector();
           Vector cols_name_vec = new Vector();
           Vector resultset_ob_vec = new Vector();
           ResultSet rs=null;
           try {
                    if(!condition.equals(""))
                    query = "select COUNT(*) as rowcount from incommingletters where "+condition+" and deleted='F'";
                     else
                    query = "select COUNT(*) as rowcount from incommingletters where deleted ='F' ";
                     rs = stmt.executeQuery(query);
                    if(rs.next()) rowcount= rs.getInt("rowcount") ;
           catch (SQLException e)
                    query_result=e.toString();
           if(rowcount!=0)
                     try
                         if(!condition.equals(""))
                          query = "select * from incommingletters where "+condition+" and deleted='F' order by srno";
                        else
                            query = "select * from incommingletters where deleted = 'F' order by srno";
                            rs = stmt.executeQuery(query);
                         query_result ="Successful";
                         ResultSetMetaData rsmd = rs.getMetaData();
                         int totcols=rsmd.getColumnCount();
                         String col;
                         for(int i=0;i<totcols;i++)
                             if(!rsmd.getColumnName(i+1).equals("type")&&!rsmd.getColumnName(i+1).equals("deleted"))
                             cols_name_vec.addElement(rsmd.getColumnName(i+1));
                            try {
                                    while (rs.next())
                                              ResultsetData rsdata = new ResultsetData();
                                              rsdata = new ResultsetData();
                                              rsdata.setSrno(rs.getInt("srno"));
                                              rsdata.setDate(rs.getDate("date"));
                                              rsdata.setRollno(rs.getString("rollno"));
                                              rsdata.setSource(rs.getString("source"));
                                              rsdata.setReciever(rs.getString("reciever"));
                                              rsdata.setSubject(rs.getString("subject"));
                                              resultset_ob_vec.addElement(rsdata);
                            catch (SQLException e)
                         Results                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         

  • I get message saying system administrator has set policies to prevent this installation; when trying to uninstall message says you do not have sufficient access to uninstall itunes please contact your administrator.  i am administrator.

    when intalling itunes i get message saying system administrator has set policies to prevent this installation; when trying to uninstall message says you do not have sufficient access to uninstall itunes please contact your administrator.  i am the dministrator.

    Windows right?
    Likely your not the administor any more, the botnet is.
    Check on this site really quick if your part of a botnet
    http://botnetchecker.com/
    All clear? Hopefully. Backup your files to a external drive, cd or dvd, USB keye etc off your computer.
    Run the sfx file on this site and it will burn to a cd.
    http://www.avira.com/en/support-download-avira-antivir-rescue-system
    Next hit your BIO's key and set the cd to boot first, run the scanner and see what it pops up.
    If your all clear then create another Admin, transfer your files over from the first Admin.
    See if that works, eventually when your totally over to the new Admin, delete the old one.
    If you can't create a new Admin, find out who locked your machine down, like your parents or it's a school computer?
    Likely installed spyware or "nanyware" to watch you.
    Hope that works.

  • I lost my Iphone 5 today in Johor Bahru. Not install Find my Phone/Icloud/Offline. How to prevent others access my email and data ? Or how to remote lost mode/locking phone ?

    I lost my Iphone 5 today in Johor Bahru. Not install Find my Phone/Icloud/Offline. How to prevent others access my email and data ? Or how to remote lost mode/locking phone ?

    suyantosdf wrote:
    I lost my Iphone 5 today in Johor Bahru. Not install Find my Phone/Icloud/Offline. How to prevent others access my email and data ? Or how to remote lost mode/locking phone ?
    If you didn't enable find my iphone in icloud settings on your phone, then you can't do a lost mode or lock your phone.
    I would assume you had a passcode on your phone to lock it.  If you didn't then start changing your passwords.
    Report the lost to your phone carrier - local authorities.

  • Use of 'static' keyword in synchronized methods. Does it ease concurrency?

    Friends,
    I have a query regarding the use of 'synchronized' keyword in a programme. This is mainly to check if there's any difference in the use of 'static' keyword for synchronized methods. By default we cannot call two synchronized methods from a programme at the same time. For example, in 'Program1', I am calling two methods, 'display()' and 'update()' both of them are synchronized and the flow is first, 'display()' is called and only when display method exits, it calls the 'update()' method.
    But, things seem different, when I added 'static' keyword for 'update()' method as can be seen from 'Program2'. Here, instead of waiting for 'display()' method to finish, 'update()' method is called during the execution of 'display()' method. You can check the output to see the difference.
    Does it mean, 'static' keyword has anything to do with synchronizaton?
    Appreciate your valuable comments.
    1. Program1
    public class SynchTest {
         public synchronized void display() {
              try {
                   System.out.println("start display:");
                   Thread.sleep(7000);
                   System.out.println("end display:");
              } catch (InterruptedException e) {
                   e.printStackTrace();
         public synchronized void update() {
              try {
                   System.out.println("start update:");
                   Thread.sleep(2000);
                   System.out.println("end update:");
              } catch (InterruptedException e) {
                   e.printStackTrace();
         public static void main(String[] args) {
              System.out.println("Synchronized methods test:");
              final SynchTest synchtest = new SynchTest();
              new Thread(new Runnable() {
                   public void run() {
                        synchtest.display();
              }).start();
              new Thread(new Runnable() {
                   public void run() {
                        synchtest.update();
              }).start();
    Output:
    Synchronized methods test:
    start display:
    end display:
    start update:
    end update:
    2. Program2
    package camel.java.thread;
    public class SynchTest {
         public synchronized void display() {
              try {
                   System.out.println("start display:");
                   Thread.sleep(7000);
                   System.out.println("end display:");
              } catch (InterruptedException e) {
                   e.printStackTrace();
         public static synchronized void update() {
              try {
                   System.out.println("start update:");
                   Thread.sleep(2000);
                   System.out.println("end update:");
              } catch (InterruptedException e) {
                   e.printStackTrace();
         public static void main(String[] args) {
              System.out.println("Synchronized methods test:");
              final SynchTest synchtest = new SynchTest();
              new Thread(new Runnable() {
                   public void run() {
                        synchtest.display();
              }).start();
              new Thread(new Runnable() {
                   public void run() {
                        synchtest.update();
              }).start();
    Output:
    Synchronized methods test:
    start display:
    start update:end update:
    end display:

    the synchronized method obtain the lock from the current instance while static synchronized method obtain the lock from the class
    Below is some code for u to have better understanding
    package facado.collab;
    public class TestSync {
         public synchronized void add() {
              System.out.println("TestSync.add()");
              try {
                   Thread.sleep(2000);
              } catch (InterruptedException e) {
                   e.printStackTrace();
              System.out.println("TestSync.add() - end");          
         public synchronized void update() {
              System.out.println("TestSync.update()");
              try {
                   Thread.sleep(2000);
              } catch (InterruptedException e) {
                   e.printStackTrace();
              System.out.println("TestSync.update() - end");          
         public static synchronized void staticAdd() {
              System.out.println("TestSync.staticAdd()");
              try {
                   Thread.sleep(2000);
              } catch (InterruptedException e) {
                   e.printStackTrace();
              System.out.println("TestSync.staticAdd() - end");
         public static synchronized void staticUpdate() {
              System.out.println("TestSync.staticUpdate()");
              try {
                   Thread.sleep(2000);
              } catch (InterruptedException e) {
                   e.printStackTrace();
              System.out.println("TestSync.staticUpdate() - end");
         public static void main(String[] args) {
              final TestSync sync1 = new TestSync();
              final TestSync sync2 = new TestSync();
              new Thread(new Runnable(){
                   public void run() {
                        sync1.add();
              }).start();
              new Thread(new Runnable(){
                   public void run() {
                        sync2.update();
              }).start();
              try {
                   Thread.sleep(3000);
              } catch (InterruptedException e) {
                   e.printStackTrace();
              new Thread(new Runnable(){
                   public void run() {
                        sync1.staticAdd();
              }).start();
              new Thread(new Runnable(){
                   public void run() {
                        sync2.staticUpdate();
              }).start();
    }

  • Which object's monitor does a synchronized method acquire?

    from the Java Tutorial for concurrency programming:
    " When a thread invokes a synchronized method, it automatically acquires the intrinsic lock _for that method's object_ and releases it when the method returns. The lock release occurs even if the return was caused by an uncaught exception. "
    what exactly does this mean?
    do synchronized methods acquire the monitors for objects of type: java.lang.reflection.Method
    please consider this code:
    public class Foo {
      private int counter = 0;
      public synchronized void incriment() { counter++; }
      public synchronized void decriment() { counter--; }
    Foo f = new Foo();
    Class[] sig = new Class[0];
    Method m = f.getClass().getMethod("incriment", sig);
    // ok. so "m" is the relevant method object.
    f.incriment(); // <-- is the monitor for "m" ,
                          // or the monitor for "f", acquired?
    .......my reading of the Concurrency Tutorial is that synchronized methods use the monitors of java.lang.reflection.Method objects?
    and thus, Foo is not thread safe, right?
    however, this simple change makes Foo thread-safe?
    public class Foo {
      private volatile int counter = 0; // "volatile"
      public void incriment() { counter++; }
      public void decriment() { counter--; }
    }thanks.
    Edited by: kogose on Feb 23, 2009 7:13 PM

    tensorfield wrote:
    jverd wrote:
    tensorfield wrote:
    kogose wrote:
    what exactly does this mean?It means you're complicating things.
    If a method is synchronized, it is. You don't need to go beyond that. The method is synchronized.Not true. You have to know what it means for a method to be synchronized. Often people come in with the erroneous impression that it somehow prevents you from using or accessing the object in any other thread.It's very simple. If a synchronized method is called at the same time from many threads only one call will be executed at a time. The calls will be lined up and performed one after the other in sequence.
    AND because synchronization is on a per object basis, when one synchronized method is being called from one thread, all synchronized methods of that same object are blocked for calling from other threads.
    Simple as that.No, it's not that simple, and as stated, that is not correct. In particular, you didn't mention that for an instance method, all the various threads have to be trying to call instance methods on the same object in order for execution to be sequential.
    You really can't understand Java's syncing without understanding how it relates to locks, and what it means for a method to be synchronized in terms of which lock it acquires.
    Edited by: jverd on Feb 25, 2009 2:47 PM

  • How to synchronize concurrent access to static data in ABAP Objects

    Hi,
    1) First of all I mwould like to know the scope of static (class-data) data of an ABAP Objects Class: If changing a static data variable is that change visible to all concurrent processes in the same Application Server?
    2) If that is the case. How can concurrent access to such data (that can be shared between many processes) be controlled. In C one could use semaphores and in Java Synchronized methods and the monitor concept. But what controls are available in ABAP for controlling concurrent access to in-memory data?
    Many thanks for your help!
    Regards,
    Christian

    Hello Christian
    Here is an example that shows that the static attributes of a class are not shared between two reports that are linked via SUBMIT statement.
    *& Report  ZUS_SDN_OO_STATIC_ATTRIBUTES
    REPORT  zus_sdn_oo_static_attributes.
    DATA:
      gt_list        TYPE STANDARD TABLE OF abaplist,
      go_static      TYPE REF TO zcl_sdn_static_attributes.
    <i>* CONSTRUCTOR method of class ZCL_SDN_STATIC_ATTRIBUTES:
    **METHOD constructor.
    *** define local data
    **  DATA:
    **    ld_msg    TYPE bapi_msg.
    **  ADD id_count TO md_count.
    **ENDMETHOD.
    * Static public attribute MD_COUNT (type i), initial value = 1</i>
    PARAMETERS:
      p_called(1)  TYPE c  DEFAULT ' ' NO-DISPLAY.
    START-OF-SELECTION.
    <b>* Initial state of static attribute:
    *    zcl_sdn_static_attributes=>md_count = 0</b>
      syst-index = 0.
      WRITE: / syst-index, '. object: static counter=',
               zcl_sdn_static_attributes=>md_count.
      DO 5 TIMES.
    <b>*   Every time sy-index is added to md_count</b>
        CREATE OBJECT go_static
          EXPORTING
            id_count = syst-index.
        WRITE: / syst-index, '. object: static counter=',
                 zcl_sdn_static_attributes=>md_count.
    <b>*   After the 3rd round we start the report again (via SUBMIT)
    *   and return the result via list memory.
    *   If the value of the static attribute is not reset we would
    *   start with initial value of md_count = 7 (1+1+2+3).</b>
        IF ( p_called = ' '  AND
             syst-index = 3 ).
          SUBMIT zus_sdn_oo_static_attributes EXPORTING LIST TO MEMORY
            WITH p_called = 'X'
          AND RETURN.
          CALL FUNCTION 'LIST_FROM_MEMORY'
            TABLES
              listobject = gt_list
            EXCEPTIONS
              not_found  = 1
              OTHERS     = 2.
          IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
          CALL FUNCTION 'DISPLAY_LIST'
    *       EXPORTING
    *         FULLSCREEN                  =
    *         CALLER_HANDLES_EVENTS       =
    *         STARTING_X                  = 10
    *         STARTING_Y                  = 10
    *         ENDING_X                    = 60
    *         ENDING_Y                    = 20
    *       IMPORTING
    *         USER_COMMAND                =
            TABLES
              listobject                  = gt_list
            EXCEPTIONS
              empty_list                  = 1
              OTHERS                      = 2.
          IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
        ENDIF.
      ENDDO.
    <b>* Result: in the 2nd run of the report (via SUBMIT) we get
    *         the same values for the static counter.</b>
    END-OF-SELECTION.
    Regards
      Uwe

  • Unexpected error occurred :concurrent access to HashMap attempted

    While runnig the ALBPM 5.7 we got this error. This looks like the ALBPM workflow engine is using HashMap in a unsynchronized way. is this a known issue and is there a work around for this?
    This error happened shortly after a possible blip in the database server, with exception message which said:
    Message:
    The connectivity to the BEA AquaLogic™ BPM Server database has been successful restablished.
    Any thoughts/insight/past experience....
    Looks like we should be using Hashtable instead of a HashMap (or atleast a Synchronized HashMap)
    This is best done at creation time, to prevent accidental unsynchronized access to the map:
    Map m = Collections.synchronizedMap(new HashMap(...));
    See Exception message below
    Message:
    An unexpected error occurred while running an automatic item.
    Details: Connector [ffmaeng_ENGINE_DB_FUEGOLABS_ARG:SQL:Oracle (ALI)] caused an exception when getting a resource of type [0].
    Detail:Connector [ffmaeng_ENGINE_DB_FUEGOLABS_ARG:SQL:Oracle (ALI)] caused an exception when getting a resource of type [0].
    Caused by: concurrent access to HashMap attempted by Thread[ET(49),5,Execution Thread Pool]
    fuego.connector.ConnectorException: Connector [ffmaeng_ENGINE_DB_FUEGOLABS_ARG:SQL:Oracle (ALI)] caused an exception when getting a resource of type [0].
    Detail:Connector [ffmaeng_ENGINE_DB_FUEGOLABS_ARG:SQL:Oracle (ALI)] caused an exception when getting a resource of type [0].
    at fuego.connector.ConnectorException.exceptionOnGetResource(ConnectorException.java:95)
    at fuego.connector.ConnectorTransaction.getResource(ConnectorTransaction.java:285)
    at fuego.connector.JDBCHelper.getConnection(JDBCHelper.java:43)
    at fuego.server.service.EngineConnectorService.getConnection(EngineConnectorService.java:260)
    at fuego.server.service.EngineConnectorService.getEngineConnection(EngineConnectorService.java:160)
    at fuego.transaction.TransactionAction.getEngineHandle(TransactionAction.java:180)
    at fuego.server.execution.EngineExecutionContext.getEngineHandle(EngineExecutionContext.java:352)
    at fuego.server.execution.EngineExecutionContext.persistInstances(EngineExecutionContext.java:1656)
    at fuego.server.execution.EngineExecutionContext.persist(EngineExecutionContext.java:1010)
    at fuego.transaction.TransactionAction.beforeCompletion(TransactionAction.java:133)
    at fuego.connector.ConnectorTransaction.beforeCompletion(ConnectorTransaction.java:654)
    at fuego.connector.ConnectorTransaction.commit(ConnectorTransaction.java:330)
    at fuego.transaction.TransactionAction.commit(TransactionAction.java:303)
    at fuego.transaction.TransactionAction.startBaseTransaction(TransactionAction.java:470)
    at fuego.transaction.TransactionAction.startTransaction(TransactionAction.java:540)
    at fuego.transaction.TransactionAction.start(TransactionAction.java:213)
    at fuego.server.execution.DefaultEngineExecution.executeImmediate(DefaultEngineExecution.java:118)
    at fuego.server.execution.DefaultEngineExecution.executeAutomaticWork(DefaultEngineExecution.java:58)
    at fuego.server.execution.EngineExecution.executeAutomaticWork(EngineExecution.java:42)
    at fuego.server.execution.ToDoItem.executeAutomaticWork(ToDoItem.java:264)
    at fuego.server.execution.ToDoItem.run(ToDoItem.java:531)
    at fuego.component.ExecutionThread.processMessage(ExecutionThread.java:754)
    at fuego.component.ExecutionThread.processBatch(ExecutionThread.java:734)
    at fuego.component.ExecutionThread.doProcessBatch(ExecutionThread.java:140)
    at fuego.component.ExecutionThread.doProcessBatch(ExecutionThread.java:132)
    at fuego.fengine.ToDoQueueThread$PrincipalWrapper.processBatch(ToDoQueueThread.java:432)
    at fuego.component.ExecutionThread.work(ExecutionThread.java:818)
    at fuego.component.ExecutionThread.run(ExecutionThread.java:397)
    Caused by: java.util.ConcurrentModificationException: concurrent access to HashMap attempted by Thread[ET(49),5,Execution Thread Pool]
    at java.util.HashMap.onExit(HashMap.java:226)
    at java.util.HashMap.transfer(HashMap.java:690)
    at java.util.HashMap.resize(HashMap.java:676)
    at java.util.HashMap.addEntry(HashMap.java:1049)
    at java.util.HashMap.put(HashMap.java:561)
    at fuego.lang.cache.CacheStatistic.lock(CacheStatistic.java:246)
    at fuego.lang.cache.TimedMultiValuatedCache.getLocked(TimedMultiValuatedCache.java:282)
    at fuego.lang.cache.TimedPool.get(TimedPool.java:80)
    at fuego.connector.impl.BaseJDBCPooledConnector.getConnection(BaseJDBCPooledConnector.java:140)
    at fuego.connector.impl.BaseJDBCConnector.getResource(BaseJDBCConnector.java:222)
    at fuego.connector.ConnectorTransaction.getResource(ConnectorTransaction.java:280)
    ... 26 more

    Hi BalusC,
    I forgot to tell one thing, the exception what I mentioned is coming very rarely. The application is in Production and they getting this Exception once in 3 months. Is there any way to re-produce the same exception number of times to check whether it has been fixed or not after installing the updates as you said. If you have any information regarding this exception please send me.
    Thank You.

  • Prblem calling synchronized method from onMessage

    Hi friends,
    I am trying to call a synchronized method "X" from onMessage method in MDB.
    I dont see any effect of synchronization....
    do i need to make the "X" method static synchronized??
    or else is there any other way ?
    I need ur help

    Hi,
    MDBs are not single threaded as messages are concurrently processed. You did not get any synchronisation as all your MDB instances (threads) are accessing a different instance of your object. But however, if you use a static synchronized method then all your MDB instances will be synchronized on the same object and that should have the expected behaviour.
    Arnaud

  • Range of synchronized method?

    Hi,
    If you have a synchronized method, which calls another method, is that other method also synchronized?
    protected synchronized void doSomething() {
        // ... some coding
        heavyNumberCrunching()
        // ... some more coding
    protected void heavyNumberCrunching() {
        // ... even more coding
    }Additions:
    1. only doSomething() calls heavyNumberCrunching()
    2. heavyNumberCrunching() reads from/writes to collections, that can be accessed by other thread. Will access to these collections (not necessarily a Vector or Hashtable) be restricted when heavyNumberCrunching is crunching away?
    Just wondering.
    Abel

    spoon_ wrote:
    Abel wrote:
    If you have a synchronized method, which calls another method, is that other method also synchronized?yes, This is incorrect.
    the lock is held from when the method begins to when it endsWhile it is true that the lock is held until the synchronized method ends, that lock does not prevent access to unsynchronized methods by other threads.
    An example:
    =============
    public class Crunch {
        Crunch() {
            Thread[] aTeam = new Thread[10];
            for (int i = 0; i < 10; i++) {
                aTeam[i] = new Thread(new Runnable() {
                    public void run() {
                        doSomething();
                }, "A Team Thread " + i);
                aTeam.start();
    Thread[] bTeam = new Thread[10];
    for (int i = 0; i < 10; i++) {
    bTeam[i] = new Thread(new Runnable() {
    public void run() {
    heavyNumberCrunching();
    }, "B Team Thread " + i);
    bTeam[i].start();
    public synchronized void doSomething() {
    heavyNumberCrunching();
    public void heavyNumberCrunching() {
    System.out.println("Crunching on thread: " + Thread.currentThread().getName());
    try {
    Thread.sleep(2000);
    } catch (InterruptedException ie) {
    ie.printStackTrace();
    System.out.println("Done crunching on thread: " + Thread.currentThread().getName());
    public static void main(String[] args) {
    new Crunch();
    The A Team threads all access the heavyNumberCrunching() method via the synchronized doSomething() method. The B Team threads call heavyNumberCrunching() directly.
    Here's some output from a run on my quad core machine:
    Crunching on thread: A Team Thread 0
    Crunching on thread: B Team Thread 0
    Crunching on thread: B Team Thread 1
    Crunching on thread: B Team Thread 2
    Crunching on thread: B Team Thread 3
    Crunching on thread: B Team Thread 4
    Crunching on thread: B Team Thread 5
    Crunching on thread: B Team Thread 6
    Crunching on thread: B Team Thread 7
    Crunching on thread: B Team Thread 9
    Crunching on thread: B Team Thread 8
    Done crunching on thread: B Team Thread 5
    Done crunching on thread: B Team Thread 4
    Done crunching on thread: B Team Thread 9
    Done crunching on thread: B Team Thread 3
    Done crunching on thread: B Team Thread 7
    Done crunching on thread: B Team Thread 1
    Done crunching on thread: B Team Thread 2
    Done crunching on thread: A Team Thread 0
    Done crunching on thread: B Team Thread 8
    Done crunching on thread: B Team Thread 6
    Done crunching on thread: B Team Thread 0
    Crunching on thread: A Team Thread 9
    Done crunching on thread: A Team Thread 9
    Crunching on thread: A Team Thread 8
    Done crunching on thread: A Team Thread 8
    Crunching on thread: A Team Thread 7
    Done crunching on thread: A Team Thread 7
    Crunching on thread: A Team Thread 6
    Done crunching on thread: A Team Thread 6
    Crunching on thread: A Team Thread 5
    Done crunching on thread: A Team Thread 5
    Crunching on thread: A Team Thread 4
    Done crunching on thread: A Team Thread 4
    Crunching on thread: A Team Thread 3
    Done crunching on thread: A Team Thread 3
    Crunching on thread: A Team Thread 2
    Done crunching on thread: A Team Thread 2
    Crunching on thread: A Team Thread 1
    Done crunching on thread: A Team Thread 1Notice while Team A Thread 1 is crunching, most of the B Team threads start and finish crunching. Nothing prevents a call to an unsynchronized block of code, even if that code is called from a synchronized block.
    Jim S.

  • Calling static synchronized method in the constructor

    Is it ok to do so ?
    (calling a static synchronized method from the constructor of the same class)
    Please advise vis-a-vis pros and cons.
    regards,
    s.giri

    I would take a different take here. Sure you can do it but there are some ramifications from a best practices perspective. f you think of a class as a proper object, then making a method static or not is simple. the static variables and methods belong to the class while the non-static variables and methods belong to the instance.
    a method should be bound to the class (made static) if the method operates on the class's static variables (modifies the class's state). an instance object should not directly modify the state of the class.
    a method should be bound to the instance (made non-static) if it operates on the instance's (non-static) variables.
    you should not modify the state of the class object (the static variables) within the instance (non-static) method - rather, relegate that to the class's methods.
    although it is permitted, i do not access the static methods through an instance object. i only access static methods through the class object for clarity.
    and since the instance variables are not part of the class object itself, the language cannot and does not allow access to non-static variables and methods through the class object's methods.

Maybe you are looking for

  • Puzzler - Is there a way to detect when an external headphone or speaker is plugged in?

    I have a puzzler, and my initial question is simply, is there a way to see via Windows if/when an external headphone or microphone is plugged in, or is that all an electrical circuit independent of the OS? Background: (not necessarily the question I'

  • How to restrict users sending/receiving mails to other domains in NMS

    In an Extranet where five domains are there, how can I prevent users to send mail only between three domains from rest of the two domains, they should not have access. sometimes sending mail fails from the same host with multiple domains.

  • Unable to install on Mac due to errors

    Hi there, Am finding it hard to install Adobe Premiere, Elements 10 on a very new MacBook Pro. Started with 3rd Disk as that is what was advised.  But gets to last part of installation and has the following errors: CAN ANYONE TELL ME HOW TO SORT THIS

  • Purchase made by error

    I was not aware that I had purchased Disco Zoo pack of 100000 Coins for $10.59 (total).  I deleted this Disco app from my phone yesterday because my children did not enjoy it.  Can I get a refund?

  • SCORM bookmarked playback resumes video but not audio

    Hi, We've published e-learning courses with Captivate 3 as SCORM 1.2 in a PIF (zipped Flash 9 + HTML).  They play fine when delivered from our SABA 5.4 LMS, with the audio and video in sync.  If we exit SABA's content player part way through the cour