Call JSP with applet and wait till it is loaded

Hi,
I am calling a JSP with a java-script. The targetpage needs some time, until the applet is loaded. I would like to call a function in the applet.
My problem is, that I cannot set 'location.href' and straight after that call the applet, because it will not be there. How can I delay the applet-call, until it is really there?
function loadOrder(){
top.mainFrame.location.href = 'auftragseditor.jsp';
top.mainFrame.OrderApplet.setOrder( orderno )
I also fitted a while(...) loop between the two statements, but obviously the page is not build up in another thread. The loading will wait.
Thanks for your help
Klaus

Assuming that top.mainFrame.OrderApplet.setOrder( orderno ) causes an exception because
the applet is not loaded yet you should put it in a try and catch.
One other problem is that orderno is not defigned anywhere in your method.
function loadOrder(){
  top.mainFrame.location.href = 'auftragseditor.jsp';
  callApplet( orderno );
function callApplet(strPassToApplet){
  try{
     top.mainFrame.OrderApplet.setOrder( orderno )
  }catch(e){
    // try again in .1 seconds
    setTimeout("callApplet(\"" + strPassToApplet + \");",100);
}

Similar Messages

  • Applescript to launch an application and wait till it exits

    I have written the applescript to launch an application and wait till it exits and but it is not working. Here is the code for that
    tell application "/Applications/Pages.app" to activate
    tell application "/Applications/Pages.app"
        repeat until it is not running
        end repeat
    end tell
    But when I tried to close the app, the script is still running. I think the reason is , even though I closed the window, that process is still running. Can you please help me to solve this problem?

    Trying to make this kind of thing work from the script editor is going to give you headaches. A better approach is to create a script application.  Copy the following code into the Script Editor, and then save it as an application with the "Stay open after run handler" checkbox checked. Then run the resulting script application directly.
    on run
      tell application "Pages" to activate
      -- add a longish delay to allow the application to start
      delay 5
    end run
    on idle
      if application "Pages" is not running then
      -- the application has quit, so go to the 'on quit' handler
      quit
      end if
    end idle
    on quit
      -- do whatever you want to do after the application has quit
      -- allow the app to quit itself
      continue quit
    end quit

  • Call a JSP from applet and display the results in the browser

    Hello All,
    I have written an applet which performs some functionality at the clinets browser. When the applets method finishes exectution, I would like to call
    a jsp. The results of the JSP should be displayed like a normal page in the browser.
    I tried creating a HttpURLConnection and calling the jsp but two things happened
    1. The jsp call failed because the applet doesn't have a valid session id.
    2. even if I disable the valid user check at the jsp, the results of the jsp are returned as a set of bytes to the applet. They are not displayed in the browser window.
    Then I tried applet.getAppletContext().showDocument()... However with this api I cannot do a POST operation on the JSP with some input data because this takes only a URL as an input parameter.
    Please help me in this problem and I will be very gratefull to you.
    1. applet uses the same session id as the browser so that when applet makes a request to the jsp it does not get user invalid exception.
    2. the results of the jsp are displayed on the browser and not given to the applet.
    Thank you so much for your help.
    regards,
    Abhishek.

    I hope this can help you
    I made a package calls fun
    and a clsss calls JspTestingFun
    package fun;
    public class JspTestingFun{
      private String sample = "welcome to jsp";
      //Access sample property
      public String getSample() {
        return sample;
      //Access sample property
      public void setSample(String newValue) {
        if (newValue!=null) {
          sample = newValue;
    }then I make a jsp file
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql" %>
    <%@ page import =  "fun.JspTestingFun"%>
    <html>
    <head>
    <title>
    jspTest
    </title>
    </head>
    <jsp:useBean id="mytest" scope="session" class="fun.JspTestingFun" />
    <jsp:setProperty name="mytest" property="*" />
    <body bgcolor="#ffffff">
    <%
    mytest.getSample();
    %>
    <h1>
    Just for testing
    </h1>
    <form method="post">
    <br>Enter anything   :  <input name="sample"><br>
    <br><br>
    <input type="submit" name="Submit" value="Submit">
    <input type="reset" value="Reset">
    <br>
    this what we get<jsp:getProperty name="mytest" property="sample" />
    </form>
    </body>
    </html> 

  • Not able to run Applet after calling JSP with a Servlet

    Dear Java-Community :)
    At first I want to say, that my English isn't the best.. so I hope you'll understand my problem ;)
    I'm running a J2EE-Application, packed in a EAR-File, on my JBoss with following directory-structur:
    /jaw6c/bin
    /jaw6c/build
    /jaw6c/common
    /jaw6c/ejb
    /jaw6c/sql
    /jaw6c/src
    /jaw6c/webapp
    /jaw6c/webapp/build
    /jaw6c/webapp/build/classes
    /jaw6c/webapp/build/classes/com
    /jaw6c/webapp/build/classes/com/jbossatwork
    /jaw6c/webapp/build/classes/com/jbossatwork/ControllerServlet.class<<<<<<<<
    /jaw6c/webapp/build/distribution
    /jaw6c/webapp/build/distribution/webapp.war
    /jaw6c/webapp/build/gensrc
    /jaw6c/webapp/compile-lib
    /jaw6c/webapp/lib
    /jaw6c/webapp/src
    /jaw6c/webapp/src/com
    /jaw6c/webapp/src/com/jbossatwork
    /jaw6c/webapp/src/com/jbossatwork/ControllerServlet.java
    /jaw6c/webapp/web
    /jaw6c/webapp/web/WEB-INF
    /jaw6c/webapp/web/WEB-INF/classes
    /jaw6c/webapp/web/buyCarForm.jsp
    /jaw6c/webapp/web/carForm.jsp
    /jaw6c/webapp/web/carList.jsp
    /jaw6c/webapp/web/copy_darstellungErgebnisse.jsp
    /jaw6c/webapp/web/darstellungErgebnisse.jsp<<<<<<<<<<<<<<
    /jaw6c/webapp/web/default.css
    /jaw6c/webapp/web/diag.jar
    /jaw6c/webapp/web/diagram.class<<<<<<<<<<<<<<<<<<<<<<<<
    /jaw6c/webapp/web/error.jsp
    /jaw6c/webapp/web/index.jsp
    /jaw6c/webapp/web/selectBewertungslaeufeList.jsp
    /jaw6c/webapp/build.xml
    /jaw6c/build.xmlThe applet should be loaded in my "darstellungErgebnisse.jsp"-File.
    Now the strange situation:
    When I access "darstellungErgebnisse.jsp" DIRECTLY by entering a URL like "localhost:8080/jaw/darstellungErgebnisse.jsp" , the applet is loading perfectly !
    But when my server is forwarding me to the JSP-Site with
    RequestDispatcher dispatcher =  getServletContext().getRequestDispatcher(destinationPage);
    dispatcher.forward(request, response);
    . . . . . . . ..I'll get a ""java.lang.ClassFormatError: Incompatible magic value 1008813135 in class file diagram
    " -Error what means (referenced on the articles I've read here), that the diagram.class Is not found !
    I have tried to put the class file in a JAR, in different locations... using the codebase and archive tag but NOTHING solved my problem.
    So my question:
    Why I'm able to access the JSP-File directly and seeing the applet but after forwarding to the JSP-File via the Servlet, I'm not able to see anything.
    Would appreciate your help
    Thank you and best regards
    Edit:
    1) I'm able to download the diag.jar and diagram.class file from different locations
    2)I recognized, that after using the servlet, my url is changing from
    localhost:8080/jaw
    to
    localhost:8080/jaw/controller
    I tried added the class file to the position, where the controller-class file is, but without sucess.
    3)Opening the class-file with a hex-editor shows me, that
    the first bytes are
    "CAFEBABE0000002E02B9070002010007"
    (http://forum.java.sun.com/thread.jspa?threadID=648990&messageID=3820701)
    Message was edited by:
    Khaled01

    Hello everybody,
    I finaly have found the solution (after 16 hours).
    Like I mentioned before, I recognized (maybe a little to late), that my path is changing when I'm using the servlet :
    localhost:8080/jaw
    to
    localhost:8080/jaw/controller
    (made by url-pattern in my web.xml).
    So when my JSP tries to acces the class file, It's looking at:
    localhost:8080/jaw/controller/applet/diagram.class
    but the file is in:
    localhost:8080/jaw/applet/diagram.class
    So the solution is, to but a codebase-tag in my applet-declaration with following delcaration "basedir="../applet"
    I hope I'll help somebody with the same problems. It took me a day to find out, that the solution was two points and a slash..... lol
    Regards to everybody

  • Calling jsp with parameter - problem

    Hi,
    i am calling another jsp in onclick event. But the parameter does seems to be passed.
    when i write like below seperately,
    <script type="text/javascript">
                   window.location.href='emp2.jsp?empcode=<%=request.getParameter("empcode")%>&descr=<%=request.getParameter("empname")%>'
    </script>
    I can see emp2.jsp with correct parameters.
    But when i use the above logic in onclick event, the empcode is missing.
    See the onclick event.
    <INPUT TYPE="submit" value="Modify" ONCLICK="window.location.href='emp2.jsp?empcode=<%=request.getParameter("empcode")%>&descr=<%=request.getParameter("empname")%>'">
    Pls help where am i doing wrong.

    Looks like it should work, provided empcode and empname are both in the request parameters when you load this page.
    If you enter in the empcode and empname on the same screen as the submit button, this won't work.
    I would suggest you just use the default action of a submit button, and submit a form.
    This should be exactly equivalent to what you have written in your onclick event.
    <form action="emp2.jsp>
    <input type="hidden" name="empcode value="<%= request.getParameter("empcode") %>"
    <input type="hidden" name="descr value="<%= request.getParameter("empname") %>"
    <input type="submit" value="Modify">
    </form>

  • Onclick event jsp with Applet

    If it is possible so give me Ans.
    i am creating jsp page and display some data and link,
    and i am clicking some link and open applet window with some result
    it is possible or not .

    possible
    these might help:
    http://www.java2s.com/Code/Java/JSP/JspAppletPlugin.htm
    and this forum:
    http://forums.sun.com/thread.jspa?threadID=224382&messageID=789775
    Edited by: alwayslearn on Sep 16, 2008 6:08 AM

  • I need help with Applets and Multithreading

    [hello all.  first time poster. big fan of java.]
    now to the important matter: Applets and Threads
    =======================================
    1) I have an applet with that implements the runnable interface, and has one thread (and a simple animation). If I try to view this applet in the applet viewer with JGrasp, it spits an insane error telling me
    "java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)"
    but, if I run the applet through a web browser, by putting it in an html document, it runs correctly, without error
    What on earth is wrong, and how do I fix it?!?
    2) I want to put 2 threads in my applet?
    If I implement the Runnable interface, I can only have one Run() method in my applet, right?
    So how do I define behaviour for 2 threads when I only have one run method in which to define the behaviour? Can I use two threads with the runnable interface, or do I have to make objects of my own defined thread classes?
    3) I tried to make 2 threads in my applet by creating my own thread classes, and instantiating them in my applet (instead of implementing the runnable interface).
    I still get the same insane error as I mentioned in my first point (which I expected), except now, the applet won't work even when viewed through a web browser!!
    Please please help me. I am frustrated beyond belief (at what is probably a very simple problem)
    I have searched and searched all over and found no answers on this

    If I try to view this applet in the applet viewer with JGrasp, it spits an insane error telling me
    "java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)"Don't know anything about JGrasp, but it runs with pretty tight security - thats what this insane error is all about. Use the appletviewer or a browser.
    If I implement the Runnable interface, I can only have one Run() method in my applet, right?Correct
    So how do I define behaviour for 2 threads when I only have one run method in which to define the behaviour?
    Can I use two threads with the runnable interface, or do I have to make objects of my own defined thread classes?You can create two Runnable implementations (classes) in your applet.
    example (missing code)
    class MyApplet extends Applet {
      void doSomething() {
      void doSomethingElse() {
      void startThreads() {
        Thread t = new Thread(new Runnable() { public void run() { doSomething();}});
        t.start();
        t = new Thread(new Runnable2());
        t.start();
      class Runnable2 implements Runnable {
         public void run() {
           doSomethingElse();
    }If the above seems confusing, read up on anonymous and inner classes.
    3) I tried to make 2 threads in my applet by creating my own thread classesTry not subclassing thread - this causes a security check

  • Dynamic Fonts in JSP With applet

    Hi Buddies
    My Multilingual web application uses a dynamic font , the technology provided by TrueDoc.com. Now the problem is the webpage works properly by making use of the dynamic fonts and I get stuck to life when I realised that my applet should also display using the dynamic font.
    The dynamic font is a file with an extension of .pfr usually placed in the server and all the webpages will be bound to the server to make use of the .pfr font, there by making all the clients to view the sam font
    irrespective of the fonts installed in the client machine.
    How do i get going

    The applet is run on the client machine, so you have to include the .pfr with the applet code. Best bet would be to use a JAR for the Applet and package the .pfr inside there.

  • Calling JSP from Forms and going back from JSP to Forms

    Hi,
    We are calling JSP from Forms 6i using show_document
    I'd like to go back to tha calling Form from the JSP.
    How can I construct the URL that would lead me back to the same Form and Forms session where the JSP was called from?
    Thanks,
    Arpad

    Thanks Shay,
    works for me too...
    Now:
    when I use the "Back" button of my IE to go back from JSP to the Forms session, it works for Jinitiator 1.1.8.19, but if I use Jinitiator 1.3 I got hung...
    Any ideas how could I make it work from Jinit 1.3?
    Thanks again/
    Regards,
    Arpad

  • Security issues with applets and windows Vista when printing to file

    Hi, everyone
    I am currently developing an application that prints out the result of some calculations.
    from a Javascript file, the output finally ends up in a java applet that should print the file in a special printer.
    For debugging purposes I have created a File printer that creates a file from the output comming to the printer; this way I can debug what commands the printer is receiving.
    This worked well on Windows Xp; Vista always asks for permissions for the applet, and altough I guarantee these permissions, printer is not allowed to create the output file and reports an error writing
    after a little research, I have found that java applets have all permissions when certificated as trusted applications; all but file creating permissions
    anyone has any idea of how could I fix this problem?
    Thanks in advance

    HI,
    Have you actually signed your applet? If the signers certificate is the trusted key store for Java it should treat your applet as trusted. You can use a self signed certificate for testing as long as the cert is in the trusted key store.
    Some links that might help:
    [http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/keytool.html]
    [http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/rsa_signing.html]
    Cheers,
    Shane

  • Issue with applet and Weblogic 8.1 SP3

    Hello,
    I have an applet that is making EJB calls to a Weblogic 8.1 SP2 app server via an IIS web server. The weblogic.ejbc tool was used to generate the stubs and skeletons and deployed into the applet.jar. The applet comes up fine in this scenario. But when this applet is connected to a Weblogic 8.1 SP3 app server it failes to come up. Apparently, there is some dependency between the ejbc generated stubs and skeletons with the service pack that is being used. One way of solving this problem is to generate separate stubs and skeletons for each service pack but I would like to avoid doing this and would like it to be transparent to the applet. Is there any configuration that I can make which can help solve this problem ?
    -Vijay

    You could check up for the relaease. I don't think there was such a change in SP3. But generating the stubs and skeletons again will definitely solve. You might even test it backwards (generate on SP3 and test on SP2).
    xH4x0r

  • WebService call from signed applet and MS Vista

    Hi.
    I'M developing a system that needs to call web services from a signed applet.
    I have made the solution like this.
    The applet starts by checking that the 12 needed libs is present under the <java home>\lib\ext folder. if not it will download the files automatically and restart the browser.
    This works fine in Windows XP because the signed applet gives me read/write access to the whole machine, but in Vista this isn't possible anymore (as i understand it).
    My question: Is it possible to put these libs in another folder that the ext lib? I have tried to define the "archive" tag in my Object tag but i get the class not found exception thrown in my face.
    If there is a solution to this i would very much like some pointers!
    If not what can i do to get access to the <java home>\lib\ext folder under Vista?
    Regards
    Michael Pallesen

    When invokin applet methods via javascript, you are accessing privileged actions from an unsafe source.
    Depending on your needs, you could either load the system variables in applet init into class variables and return the information contained in the class variables to javascript or wrap the method calls inside AccessController.doPrivileged() calls.

  • Help with applets and shape/pixel detection

    hi
    im currently trying to write my first propear programming project, its a little evolving ecosystem but ive hit a stumbling block. im trying to write a method which returns an array of positions around a calling creatures location filled with numbers that refer to its surroundings, in the snippet below it places a 1 in reference to a prey. the method performs a pixel by pixel search of x y matches in an area around the calling creature, it then decides what location the reference is to be placed by working out which range of positions it is in.
    unfortunately no one seems to recognise anybody or behave in the manner in which im encoding them to. i suspect its problem with my basic (and im sure crude) algorithm. if anyone has the time or indeed the inclination to look over this code and offer some opinion i would be very greatful indeed. or has anyone worked on a problem similar to this and could offer me some advice.
    thanks
    for(int index = 0; index < prey.size(); index++)
    otherx = ((Prey)prey.get(index)).getXcord();
    othery = ((Prey)prey.get(index)).getYcord();
    for(int i = -8; i < 9; i++)
    for(int j = -8; j < 9; j++)
    if(otherx == xpos + i && othery == ypos + j && otherx != xpos
    && othery != ypos )
    if(otherx <= xpos && otherx > (xpos - 8)
    && othery > (ypos + 3) && othery < (ypos + 8))
         objectsaround[zero] = 1;
    else if(otherx <= xpos && otherx > (xpos - 8)
    && othery >= ypos && othery < (ypos + 4))
         objectsaround[one] = 1;
    else if(otherx <= xpos && otherx > (xpos - 8)
    && othery <= ypos && othery > (ypos - 8))
         objectsaround[two] = 1;
    else if(otherx >= xpos && otherx < (xpos + 4)
    && othery <= ypos && othery > (ypos - 8))
         objectsaround[three] = 1;
    else if(otherx > (xpos + 3) && otherx < (xpos + 8)
    && othery <= ypos && othery > (ypos - 8 ))
         objectsaround[four] = 1;
    else if(otherx > (xpos + 3) && otherx < (xpos + 8)
    && othery >= ypos && othery < (ypos + 4))
         objectsaround[five] = 1;
    else if(otherx > (xpos + 3) && otherx < (xpos + 8)
    && othery > (ypos + 3) && othery < (ypos + 8))
    objectsaround[six] = 1;
    else if(otherx >= xpos && otherx < (xpos + 4)
    && othery > (ypos + 3) && othery < (ypos + 8))
    objectsaround[seven] = 1;
    }

    I'm reposting the code with the formatting tags so that I can read it.
    for(int index = 0; index < prey.size(); index++)
    otherx = ((Prey)prey.get(index)).getXcord();
    othery = ((Prey)prey.get(index)).getYcord();
    for(int i = -8; i < 9; i++)
    for(int j = -8; j < 9; j++)
    if(otherx == xpos + i && othery == ypos + j && otherx != xpos && othery != ypos )
    if(otherx <= xpos && otherx > (xpos - 8) && othery > (ypos + 3) && othery < (ypos + 8))
         objectsaround[zero] = 1;
    else if(otherx <= xpos && otherx > (xpos - 8) && othery >= ypos && othery < (ypos + 4))
         objectsaround[one] = 1;
    else if(otherx <= xpos && otherx > (xpos - 8) && othery <= ypos && othery > (ypos - 8))
         objectsaround[two] = 1;
    else if(otherx >= xpos && otherx < (xpos + 4) && othery <= ypos && othery > (ypos - 8))
         objectsaround[three] = 1;
    else if(otherx > (xpos + 3) && otherx < (xpos + 8) && othery <= ypos && othery > (ypos - 8))
         objectsaround[four] = 1;
    else if(otherx > (xpos + 3) && otherx < (xpos + 8) && othery >= ypos && othery < (ypos + 4))
         objectsaround[five] = 1;
    else if(otherx > (xpos + 3) && otherx < (xpos + 8) && othery > (ypos + 3) && othery < (ypos + 8))
    objectsaround[six] = 1;
    else if(otherx >= xpos && otherx < (xpos + 4) && othery > (ypos + 3) && othery < (ypos + 8))
    objectsaround[seven] = 1;

  • Probem with applet and servlets

    subject "not able to invoke applet from servlets"
    i have attached files also..
    Respected sir,
    I am thomas from prateek techologies ,referred by madam Pratibha.
    Actually i have to plot point marks on a image(it is a Banglore map) in an applet(Uploadimg3.java).so, for doing so, iam getting values from database in my servlet file named Mapuser_sev.java
    which is in the directory
    WEB-INF/classes.
    now after fetching the values ,i am not able invoke the Applet (Uploadimg3.java)which is in the directory
    WEB-INF/classes/mapuser.
    i have used the api ,response.sendredirect("/prakash/jspfiles/displaymap1.jsp");-->up to here it's ok..
    I have used the plugin tag as follows:-
    displaymap1.jsp
    <html>
    <body>
    <jsp:plugin type="applet" code="Uploadimg3.class" codebase="WEB-INF/classes/mapuser" width="400" height="400">
    </jsp:plugin>
    </body>
    </html>
    if the plugin tag is wrong then please send me the correct coding for "jsp: plugin" with explaination.
    this is my directory hierarchy..
    jspfiles-->directory(folder)
    Prakash/jspfiles/displaymap1.jsp ----->this file has the plugin tags as mentioned above..
    Prakash is my context..
    WEB-INF/
    classes/Mapuser_serv.class -----> this is a servlet file
    mapuser/
    Uploadimg3.java -----> this is a Applet file
    Uploadimg3.class
    Mapuser1.java ---> i used this file to fetchdata from db ,please forget this file ..
    Mapuser1.class
    with regards,
    Thomas..

    It might be the restrictions java has about opening files in a web browser. I don' t know if it's allowed or not..

  • Concurrency with locks and wait/signal. Is it ok?

    Hello,
    I'm relatively new in concurrency. I've write this code that seems to work, but I'm not sure if there is any error (the concurrency concepts are not still clear for me).
    In the following class "diskFile", I'll start 10 threads executing the class "diskCacheDataOneCall". The question is that the "populateCacheFromDisk" method should wait until 10 threads are finished and, if any thread produces an error, interrupt all threads and finish.
    The code seems to work, but I have some questions like if I should synchronize the static variables Lock and Condition before using them.
    Anyway, I'd like that an "expert" on concurrency tells me if this code is acceptable, or what kind of improvements can do (or, if there is some mistake, how to correct it).
    I've spent many time reading tutorials about concurrency, and this is the result. Really, I'm not sure if I'm doing the things well, that's why I need the opinion of an expert in order to get better on concurrency.
    Thanks in advance.
    public class diskFile
    // Static variables for threading.
    public static Lock lock = null;
    public static Condition cdFinished = null;
    public static int numActiveThreads = 0;
    public static Exception loadException = null;
    // Main function
    public static void populateCacheFromDisk() throws cacheServletException
    ArrayList<Thread> arrThread = new ArrayList<Thread>();
    // Init static variables.
    lock      = new ReentrantLock();
    cdFinished      = lock.newCondition();     
    numActiveThreads = 0;
    loadException = null;
    try
    // Iterate 10 times (for simplicity) ...
    for (int i = 0; i < 10; i++)
    // Create THREAD and store its reference
    Thread thr = new Thread(new diskCacheDataOneCall());
    thr.start();
    arrThread.add(thr);
    // Increment "numActiveThreads"
    lock.lock();
    numActiveThreads++;
    lock.unlock();
    // Her we wait while no error happens and still active threads
    lock.lock();
    while ( (loadException == null) && (numActiveThreads > 0) )
    cdFinished.await();
    // If an error happens in any thread, then interrupt every active thread.
    if (loadException != null)
    for (int i = 0; i < arrThread.size(); i++)
    Thread thr = arrThread.get(i);
    if (thr.isAlive()) thr.interrupt();
    throw loadException;
    catch (Exception e) { throw new cacheServletException(); }
    finally { lock.unlock(); }
    public class diskCacheDataOneCall implements Runnable
    public diskCacheDataOneCall() {}     
    public void run()
    try
         diskFile.getCacheDataFromDiskOneCall(); // Load data from disk.
    // Decrement "numActiveThreads"
         diskFile.lock.lock();
         diskFile.numActiveThreads--;
    catch (Exception e)
    diskFile.lock.lock();
    diskFile.loadException = e;
    finally
    // Always signal and unlock.
    diskFile.cdFinished.signal();
    diskFile.lock.unlock();
    }

    Hello David,
    Sorry but the code does not work. An IllegalMonitorStateException is throwed. Here I show you a simplified version (now with ThreadPoolExecutor):
       // Main class (it triggers "maxActive" threads)
       Lock lock  = new ReentrantLock();
       Condition cdFinished = lock.newCondition();       
       numActiveThreads = 0;
       loadException = null;
       try
        ExecutorService ex = Executors.newFixedThreadPool(numActiveThreads);
        for (int i = 0; i < numActiveThreads; i++) ex.execute(arrTasks.get(i));
        lock.lock();
        while ( (loadException == null) && (numActiveThreads > 0) )
                   cdFinished.await();
        ex.shutdown();
       catch (Exception e) { throw e; }
       finally { lock.unlock(); }
      // Every thread.
      public void run()
       try
        doSomething();
        diskFile.lock.lock();
        diskFile.numActiveThreads--;
       catch (Exception e)
        diskFile.lock.lock();
        diskFile.loadException = cse;
       finally
        diskFile.cdFinished.signal();
        diskFile.lock.unlock();
      }The exception is:
    // Fail in the "signal" (finally section)
    Exception in thread "pool-1-thread-1" java.lang.IllegalMonitorStateException
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.signal(AbstractQueuedSynchronizer.java:1666)
    at com.vcfw.cache.cache.disk.diskCacheDataOneCall.run(diskCacheDataOneCall.java:44)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
    at java.lang.Thread.run(Thread.java:595)
    // Fail in the "unlock" (finally section)
    Exception in thread "pool-1-thread-2" java.lang.IllegalMonitorStateException
    at java.util.concurrent.locks.ReentrantLock$Sync.tryRelease(ReentrantLock.java:125)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.release(AbstractQueuedSynchronizer.java:1102)
    at java.util.concurrent.locks.ReentrantLock.unlock(ReentrantLock.java:431)
    at com.vcfw.cache.cache.disk.diskCacheDataOneCall.run(diskCacheDataOneCall.java:43)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
    at java.lang.Thread.run(Thread.java:595)
    Some threads fail executing the signal, and some threads fail executing ythe unlock. An IllegalMonitorStateException seems to mean that the lock was not acquired by the thread, but I'm not able to see the mistake.
    Can you help me?
    Thanks.

Maybe you are looking for