Thread destroy problem

I have a thread that is started in the main method
thread1.start();I am trying to ensure thread saftey by having a finally block that is executed in the run method this should close the thread
thread1.destroy();However I think because it is in a different method it is not recognising thread1.destroy
is my logic totally wrong here?

I am trying to ensure thread saftey by having a
finally block that is executed in the run method this
should close the thread
thread1.destroy();
How clever.
However I think because it is in a different method it
is not recognising thread1.destroyThe variable is out of scope if you've declared it as a local variable. Declare it as a member variable (non-static preferably). And it might even work.
>
is my logic totally wrong here?Unfortunately yes, and since you're posting a Thread question on "New To Java Technology" I share your pain.

Similar Messages

  • Thread.destroy() no such method error

    im trying to destroy threads on my multi-threaded server as the connection to the client that that thread was for is terminated.
    when i call destroy on the thread that contains the connection to the client that is disconnection it throws a runtime error:
    Exception in thread "Thread-3" java.lang.NoSuchMethodError
    at java.lang.Thread.destroy(Thread.java:870)
    at ClientWorker.run(Server.java:55)
    at java.lang.Thread.run(Thread.java:595)
    when closing, the window listener for the client will send out one last message: "disconnect" and in response the ClientWorker class will get its thread and destroy it. but it wont let me destroy it... why?

    public void run(){
    Connect();
    while(!socket.isClosed())
    try{
              line = in.readLine();
              if (line == null || line.equals("/disconnect"))
    try{
         client.close();
         server.removeUser(this);
              break;
         } catch(IOException ioe)
              System.out.println("Could not close " + this);
              break;
         else
    server.echoMessage(line);
         } catch (IOException e) {
         e.printStackTrace();
                      break;
        finally
            try { socket.close(); } catch (IOException exc) {}
    }

  • Killing a thread ( runnable ) - problem

    Hi,
    I already posted about this, and got a good answer.
    But, I still have a probalem :
    Here is a piece of my code :
    // this is the bean which is in the EPN and I want it to create a thread that prints something :
    public class EventListener implements StreamSink,com.bea.wlevs.ede.api.DisposableBean ,InitializingBean {
    // the relevant methods:
    RunnableTestBean runnableTestBean; // this is the thread which suppose to print ..
    public void destroy() throws Exception {
              System.out.println("destroydestroydestroydestroydestroydestroydestroy");
              runnableTestBean.suspend();
         public void afterPropertiesSet() throws Exception {
              runnableTestBean=new RunnableTestBean();
              runnableTestBean.run();
              //System.out.println("afterPropertiesSetafterPropertiesSetafterPropertiesSet");
    and the class RunnableTestBean :
    public class RunnableTestBean implements RunnableBean {
         boolean stopped=false;
         public void run() {
              while ( !stopped){
                   System.out.println(" printing...");
                   try {
                   wait(5000);
                        //Thread.sleep(1000);
                   } catch (InterruptedException e) {
                        System.out.println(" Stoping thread ??");
                        e.printStackTrace();
         public void suspend() throws Exception {
              stopped=true;
    The thing is that when I use the method as above :
    public void run() {
              while ( !stopped){
                   System.out.println(" printing...");
                   try {
                   wait(5000);
                        //Thread.sleep(1000);
                   } catch (InterruptedException e) {
                        System.out.println(" Stoping thread ??");
                        e.printStackTrace();
    When I undeploy the application , the destoy method ( in EventListener class ) is not called !
    but,
    if I implement the run "run" method like this :
    public void run() {
    System.out.println(" Something ");
    than everything is fine!
    The differrence as you can see , is that when I use an infinite loop - the destroy method never called ( seems that the caller waits for it to stop , and that's why the
    destroy method not called )
    When i don't use the infinaie loop- it's OK.
    So, any help ?
    Thanks ..

    Looking at the code that you have posted, the problem is that you are calling runnablebean.run() method in afterPropertiesSet (instead of starting a thread in which the run method is called). So, it looks like it will get stuck in afterPropertiesSet for ever.
    The recommended approach for what you are trying to do is to make the EventListener class implement RunnableBean (instead of having a separate class that implements RunnableBean that gets called from afterPropertiesSet). This means that at application startup time, this EventListener's run() method will be called by OCEP framework code in a separate thread. You can still use the suspend() method to stop the thread similar to how you are doing in your code now.

  • Java Threads compilation problem

    Hi everyone,
    I've having problems getting a simple thread program to compile, the programs says " ; " expected when there is already one present. I've gone through the program many times and still can't put my finger on whats going wrong. If someone could take a quick look and if possible tell me where I am going wrong.
    Many Thanks
    Its class ThreadA that will not compile
    ***code********************************************
    public class ThreadA extends Thread
    private int id;
    public ThreadA(int i) (id = i);
    public void run()
    for (int i=0}; i < 10; i++);
    try {sleep(1000};)catch (InterruptedException e)();
    System.out.println("Output from Thread " + id);
    import java.io.*;
    public class TestThreads1
    public static void main (String args [] )
    Thread t1 = new ThreadA (1);
    Thread t2 = new ThreadA (2);
    Thread t3 = new ThreadA (3);
    t1.start();
    t2.start();
    t3.start();
    **code***********************************************************

    public class ThreadA extends Thread
    private int id;
    public ThreadA(int i) (id = i); // <-- problem
    public void run()
    for (int i=0}; i < 10; i++); // <-- two problems
    try {sleep(1000};)catch (InterruptedException e)(); // <-- more problems
    System.out.println("Output from Thread " + id);
    }

  • 64-bit JNI C++ to JAVA invocation multiple threads classloader problem

    Hi ALL,
    I have a C++ app that invokes Java classes on 64-bit Solaris 10 with 64-bit JVM.
    Here is the problem:
    The native non-main (not the thread that initializes the JVM) threads would not be able to find any user-define class.
    Here are the symptoms and observations:
    1. JNIEnv::ExceptionDescribe() showed the following StackOverflowError:
    Exception in thread "Thread-0" java.lang.StackOverflowError
            at java.util.Arrays.copyOf(Arrays.java:2734)
            at java.util.Vector.ensureCapacityHelper(Vector.java:226)
            at java.util.Vector.addElement(Vector.java:573)
            at java.lang.ClassLoader.addClass(ClassLoader.java:173)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
            at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)2. The "main thread" that instantiates the JVM has no problem finding and loading any class or method
    3. But the other threads (non-main threads) would not be able to find the user-defined classes unless the classes were already loaded by the main thread.
    4. The non-main threads can find the "standard" java classes with no problem
    5. The same app ran fine on 32-bit system.
    6. Except for the JVM reference is global, each thread acquired JNIEnv by either GetEnv() or AttachCurrentThread().
    Any idea why it is a problem with 64-bit?
    I have the sample program to reproduce this issue in this thread: http://forums.sun.com/thread.jspa?messageID=10885363&#10885363. That was the original thread I raised but I have narrowed it down to a more concrete scenario. That's why I am creating this new thread. I hope this does not break any rule on this forum. If it does, I apologize.
    I really appreciate it if anyone can provide any help/suggestion.
    Regards,
    - Triet

    Here is the sample program. Again, this works on 32-bit but not 64-bit.
    #include <string>
    #include "jni.h"
    #include "TestThread.h"
    static JavaVM *g_pjvm = NULL;  /* denotes a Java VM */
    static JNIEnv *g_penv = NULL;  /* pointer to native method interface */
    void initJVM(char** jvmOptions) {
        printf("RJniTest init starts...\n");
        JavaVMInitArgs vm_args; /* JDK/JRE 6 VM initialization arguments */
        JavaVMOption* poptions;
        int optionLen = 0;
        while (jvmOptions[optionLen]) {
            optionLen++;
        printf("RJniTest::init len=%d\n", optionLen);
        if (optionLen > 0) {
            printf("RJniWrapper::init jvmOptions\n");
            poptions = new JavaVMOption[optionLen];
            //poptions[0].optionString = "-Djava.class.path=/usr/lib/java";
            int idx = 0;
            while (jvmOptions[idx]) {
                poptions[idx].optionString = jvmOptions[idx];
                idx++;
        printf("RJniTest::init vm_args: version(%x), nOptions(%d)\n",
                JNI_VERSION_1_6, optionLen);
        vm_args.version = JNI_VERSION_1_6;
        vm_args.nOptions = optionLen;
        vm_args.options = poptions;
        vm_args.ignoreUnrecognized = JNI_FALSE;
        // load and initialize a Java VM, return a JNI interface
        // pointer in env
        printf("RJniTest::init creates JVM\n");
        JNI_CreateJavaVM(&g_pjvm, (void**)&g_penv, &vm_args);
        printf("RJniTest init ends\n");
    void findClass(const char* classname) {
        static const char* fname = "justFindClasses";
        printf("%s: findClass: %s\n", fname, classname);
        JNIEnv* jenv;
        jint ret = g_pjvm->GetEnv((void**)&jenv, JNI_VERSION_1_6);
        if (ret == JNI_EDETACHED) {
            ret = g_pjvm->AttachCurrentThread((void**)&jenv, NULL);
            if (ret != JNI_OK || jenv == NULL) {
                printf("%s: get env error: ret=%d\n", ret, fname);
            } else {
                printf("%s: got new env\n", fname);
        } else if (ret == JNI_OK) {
            printf("%s: env already there\n");
        jclass classref;
        classref = jenv->FindClass(classname);
        if (classref == NULL) {
            printf("%s: %s class not found!\n", fname, classname);
            if (jenv->ExceptionOccurred()) {
                jenv->ExceptionDescribe();
                jenv->ExceptionClear();
        printf("%s: found class: %s\n", fname, classname);
    class RJniTestThread : public TestThread {
    public:
        void threadmain();
    void RJniTestThread::threadmain() {
        printf("RJniTestThread::threadmain: Starting testing\n");
        findClass("org/apache/commons/logging/Log");
        findClass("java/util/List");
        printf("RJniTestThread::threadmain: done.\n");
    int main(int argc, char** argv) {
        char **jvmOptions = NULL;
        printf("RJniTestDriver starts...\n");
        if (argc > 1) {
            jvmOptions = new char*[argc];
            for (int i = 0; i < argc ; i ++) {
                jvmOptions[i] = argv[i + 1];
            jvmOptions[argc - 1] = NULL;
        } else {
            int size = 8;
            int i = 0;
            jvmOptions = new char*[size];
            jvmOptions[i++] = (char*) "-Djava.class.path=<list of jar files and path here>";
            jvmOptions[i++] = (char*) "-Djava.library.path=/sandbox/mxdev/3rdparty/java/unix/jdk1.6.0_14/jre/lib/sparc";
            jvmOptions[i++] = (char*) "-Djava.compiler=NONE";
            jvmOptions[i++] = (char*) "-verbose:jni";
            jvmOptions[i++] = (char*) "-Xcheck:jni";
            jvmOptions[i++] = NULL;
        printf("init JVM\n");
        initJVM(jvmOptions);
        // UNCOMMENT HERE
        // findClass("org/apache/commons/logging/Log");
        // findClass("java/util/List");
        // UNCOMMENT END
        printf("start test thread\n");
        RJniTestThread testThread;
        ThreadId tid = testThread.launch();
        printf("wait for test thread\n");
        int ret = pthread_join(tid, NULL);
        printf("RJniTestDriver ends\n");
    }

  • Error thread java : problem with the function "resume 0x***"  (forum sun)

    One problem with the function of jdb occured when I tried to use it to
    pilot the processor with differents threads. In fact, I use a simple example with 2 threads.
    I stop the two threads with two breakpoint, and I want to resume one or the other (with the function "resume 0x****"), the one wich I resumed stop again on the breackpoint and I decide again to resume one or the other. All of that to obtain a tree of execution.
    I give you the code of the class and the code of jdb.
    CLASS: (it's just a object Room with a variable degre that I increment and decrement with two threads increase and decrease)
    public class Test{
         public static void main(String[] args){
              Room r = new Room();
              decrease de = new decrease(r);
              increase in = new increase(r);
              de.start();
              in.start();
    class Room {
         private volatile int degre=20;
         public void more(){
         degre += 4;
         public void less(){      
         degre -= 3;
    class decrease extends Thread{
    private Room room;
    public decrease(Room r){
              room =r;
    public void run(){
    try{ 
         while (!interrupted()){ 
              room.less();
    catch(InterruptedException e) {}
    class increase extends Thread{
    private Room room;
    public increase(Room r){
         room =r;
    public void run(){ 
         try{ 
              while (!interrupted()){
                   room.more();
    catch(InterruptedException e) {}
    JDB:
    Initializing jdb ...
    stop at Test:7Deferring breakpoint Test:7.
    It will be set after the class is loaded.
    runrun Test
    Set uncaught java.lang.Throwable
    Set deferred uncaught java.lang.Throwable
    >
    VM Started: Set deferred breakpoint Test:7
    Breakpoint hit: "thread=main", Test.main(), line=7 bci=30
    7 in.start();
    main[1] stop at room:16
    Set breakpoint room:16
    main[1] stop at room:20
    Set breakpoint room:20
    main[1] resume
    All threads resumed.
    >
    Breakpoint hit: "thread=Thread-0", room.less(), line=20 bci=0
    20 degre -= 3;
    Thread-0[1] threads
    Group system:
    (java.lang.ref.Reference$ReferenceHandler)0x10d Reference Handler cond. waiting
    (java.lang.ref.Finalizer$FinalizerThread)0x10c Finalizer cond. waiting
    (java.lang.Thread)0x10b Signal Dispatcher running
    Group main:
    (decrease)0x146 Thread-0 running (at breakpoint)
    (increase)0x147 Thread-1 running (at breakpoint)
    (java.lang.Thread)0x148 DestroyJavaVM running
    Thread-0[1] resume 0x147
    Thread-0[1]
    Breakpoint hit: "thread=Thread-1", room.more(), line=16 bci=0
    16 degre += 4;
    Thread-1[1] resume 0x147
    Thread-1[1]
    Breakpoint hit: "thread=Thread-1", room.more(), line=16 bci=0
    16 degre += 4;
    Thread-1[1] print degre
    degre = 24
    Thread-1[1] resume 0x146 //It's here the problem, thread 0x146 have to stop on the //next breakpoint of decrease but nothing happen
    Thread-1[1] resume 0x147
    Thread-1[1]
    Breakpoint hit: "thread=Thread-1", room.more(), line=16 bci=0
    16 degre += 4;
    Thread-1[1] clear
    Breakpoints set:
    breakpoint Test:7
    breakpoint room:16
    breakpoint room:20
    PS: I tried many other examples with other class and other kind of breakpoints, but, in any cases, on thread doesn't manage to resume. When I try with general resume (no specification of the thread), It works but it isn't interresting for me because I want to decide wich thread continue his execution.

    Hi,
    I have read the FAQ of the JMF.
    The problem was the jar files of the JMF were not in the JRE\BIN\EXT
    folder of the Java runtime!
    now it works!
    thanks
    Reg

  • Nokia 603 SMS thread view problem

    Hi All, My nokia 603 is unable to display the message in thread view. whenever the SMS is sent or recieved it will show some random integers. but if i enter to the folder view I am able to view the entire message. This is happening all of a sudden without any change done in the phone. Some one pls clarify whether it is the known issue, if so please gimme the solution. Thanks, Muralids

    Hi muralids,
    Thank you for your post. 
    We haven't confirmed if this is a known bug as it's not included in the list of Nokia 603 reported issues posted here: Firmware change logs for Symbian (S60) devices.
    However, you may try these troubleshooting steps to fix the problem:
    1. Check if the conversation view is still activated. Go to Menu, tap on Messaging, and then hit Options ( ≡ ). After that, choose View folders, hit Options ( ≡ ) again, and then select Message View. Set it to Conversations View.
    2. If the first option didn't work, try the steps provided in this link: Nokia 603 - Need help in fixing a problem?
    Hope this information helps. Cheers! 

  • Thread Problem - (Thread Blocking Problems?)

    Hi Friends
    In my program while using thread i found a problem in this code .
    In this whlie running the 'msg' was printen only after all 5 inputs are given .
    why i was not getting output after one input.why the thread out was waiting for remaining threads input.
    my code is
    import java.io.*;
    class MyThread extends Thread
      BufferedReader bin;
       MyThread()
         super();
         start();
       public void run()
          try
           bin=new BufferedReader(new InputStreamReader(System.in));
           String msg=bin.readLine();
           System.out.println(msg);
          catch(IOException e)
             System.out.println(e);
    public class Threads
         public static void main(String args[])
              for(int i=0;i<5;i++)
                new MyThread();
    }

    Hi Friends
    In my program while using thread i found a problem
    em in this code .
    In this whlie running the 'msg' was printen only
    after all 5 inputs are given .
    why i was not getting output after one input.why
    hy the thread out was waiting for remaining threads
    input.Probably because of how the scheduler was rotating among the threads while waiting for input and queueing up output.
    When you call readLine, that thread blocks until a line is available. So it probably goes to the next thread's readLine, and so on. All threads are probably blocked waiting for input before you enter a single character.
    Something inside the VM has to coordinate the interaction with the console, and between that and your threads, the out stuff just doesn't get a chance to display right away.
    In general, you can't predict the order of execution of separate threads.

  • Thread concurrency problem - how to know when thread is dead?

    My applet uses a thread to draw an iteration graph step by step.
    The user as the option of pressing two buttons:
    - PLAY button - iteration Points are stored in an arrayList and drawn step by step (a sleeping time follows each step) (drawIterations thread)
    - TO_END button - iteration Points are all stored in the arrayList (swingworker thread) and after all of them have been stored the graph is drawn instantly.
    I have problems in this situation:
    When executing the PLAY-button thread, if the user presses TO_END button, the remaining graph lines should draw instantly. Sometimes I get more points on the graph than I should. It seems that the PLAY thread, which I stop when TO_END buton is pressed, still remains storing new points into the arrayList concurrently to the new thread created after TO_END button was pressed .
    Any ideas?
    I'm already using synchronization.
    private volatile Thread drawIterations;
    public void playButtonClick(JToggleButton btn) {
         pointSet1 = new ArrayList<Point2D.Double>();
         if (drawIterations == null) drawIterations = new Thread(this,   "drawIterations");
         drawIterations.start();
    public void toEndButtonClick(JToggleButton btn) {
         stopThread() ;
         pointSet1 = new ArrayList<Point2D.Double>();
         computeIterationGraphPointsAndRefreshGraph();
    public synchronized void stopThread() {
         drawIterations = null;
         notify();
    private void computeIterationGraphPointsAndRefreshGraphs() {
         SwingWorker worker = new SwingWorker() {
              public Object construct() {
                   // compute all iteration points
                         //repaint graph
         worker.start();
    }Is there a way of testing if a thread is actually dead after setting the thread object to null??

    In general, a Thread keeps running until it's run
    method completes. Threads don't stop when their
    handle is set to null. Your run method should
    constantly be checking on a variable to know when to
    stop running and exit the run method. In this case,
    you could check on the drawIterations variable to see
    if it's null.<br>
    <br>Even using the following line on my run method I get the the same problem:
    <br>
    <br>while (myThread == drawIterations && drawIterations!=null && halfStep < 2 * totalIterations) {
    <br>...
    <br>
    <br>Here's the whole method:
    <br>(actually there are 2 graphs being drawn and the second is only refreshed every 2 steps:)
    <br>
    <br>     <br>public void run() {
         <br>  Thread myThread = Thread.currentThread();
         <br>  int totalIterations = transientIterations +iterationsToDraw ;
              <br>  while (myThread == drawIterations && drawIterations!=null && halfStep < 2 * totalIterations) {
              <br>     computeNextHalfIterationGraphPoint( );
              <br>      if (!TRANSIENT_IS_ENABLED || halfStep >= 2*transientIterations ) {// is     not in transient calculations
              <br>                       graphArea1.repaint();
              <br>                       if (halfStep%2 ==0 ) graphArea2.repaint();
              <br>                       if (halfStep < 2*totalIterations){//no need to execute the following block if at last iteration point
                   <br>                         if (lastIterationPointsFallOutsideGraphArea(toEndCPButtonActive)) break;
                        <br>          try {
                             <br>                      Thread.sleep(sleepingTimeBetweenHalfIterationRendering);
                             <br>                      if (threadInterrupted ){//if clause included to avoid stepping into a synchronized block if unnecessary
                                  <br>                        synchronized (this) {
                                       <br>                          while (threadInterrupted && myThread==drawIterations ) wait();
                                                      <br>    }
    <br>                                               }
         <br>                                   } catch (InterruptedException e) {
              <br>                                     break;
                   <br>                         }     
                        <br>               }
    <br>                            }
         <br>        stopThread();
         <br>     }
    <br>

  • Thread scheduling problem in WLS5.1

    We use a Timer Servlet to schedule some back end tasks, however we found
              that from time to time the thread scheduling often get delayed or ahead in a
              outragous magtitude.
              We run the servlet inside WLS, and right after start up, the timer works
              perfect, but after long enough time (more than one day), the timer started
              to behave weird. It could get delayed for as much as hours, and then
              suddenly fired up all delayed tasks in a very short period of time. We then
              try to run a very simple Timer doing only wake up every 10 minutes and print
              one line, that failed too. We are running WLS5.1+sp3 on
              Solaris2.6(Generic_105181-19 sun4u sparc SUNW,Ultra-5_10) with jdk1.2.1_04.
              BTW, we found that it ran well on NT, at least for three days without
              problem.
              Any feedback will be appreciated!
              Qingxiang Ke
              below is the source for the simple timer, and deploy properties for it
              inside weblogic.properties file.
              SimpleTimerServlet.java
              package com.cysive.test;
              import java.io.*;
              import java.util.*;
              import javax.servlet.*;
              import javax.servlet.http.*;
              public class SimpleTimerServlet extends HttpServlet
              class Sleepy implements Runnable
              public void run()
              while(true)
              try
              long wakeUpTime = 600 * 1000;
              Thread.currentThread().sleep(wakeUpTime);
              System.out.println(new Date().toString() + " SimpleTimer Yawn
              ............ Yawn ............");
              catch(InterruptedException ie){}
              private static boolean timerIsRunning = false;
              public void init()
              if(! timerIsRunning)
              Thread sleepy = new Thread(new Sleepy());
              sleepy.start();
              timerIsRunning = true;
              public void doGet(HttpServletRequest request,
              HttpServletResponse response)
              throws IOException, ServletException
              doPost(request, response);
              public void doPost(HttpServletRequest request,
              HttpServletResponse response)
              throws IOException, ServletException
              OutputStream os = response.getOutputStream();
              os.write("look at your std out!!!".getBytes());
              os.flush();
              os.close();
              deploy properties in weblogic.properties
              weblogic.httpd.register.simpletimer=com.cysive.test.SimpleTimerServlet
              weblogic.system.startupClass.servletSimpleTimer=weblogic.servlet.utils.Servl
              etStartup
              weblogic.system.startupArgs.servletSimpleTimer=servlet=simpletimer
              

    We use a Timer Servlet to schedule some back end tasks, however we found
              that from time to time the thread scheduling often get delayed or ahead in a
              outragous magtitude.
              We run the servlet inside WLS, and right after start up, the timer works
              perfect, but after long enough time (more than one day), the timer started
              to behave weird. It could get delayed for as much as hours, and then
              suddenly fired up all delayed tasks in a very short period of time. We then
              try to run a very simple Timer doing only wake up every 10 minutes and print
              one line, that failed too. We are running WLS5.1+sp3 on
              Solaris2.6(Generic_105181-19 sun4u sparc SUNW,Ultra-5_10) with jdk1.2.1_04.
              BTW, we found that it ran well on NT, at least for three days without
              problem.
              Any feedback will be appreciated!
              Qingxiang Ke
              below is the source for the simple timer, and deploy properties for it
              inside weblogic.properties file.
              SimpleTimerServlet.java
              package com.cysive.test;
              import java.io.*;
              import java.util.*;
              import javax.servlet.*;
              import javax.servlet.http.*;
              public class SimpleTimerServlet extends HttpServlet
              class Sleepy implements Runnable
              public void run()
              while(true)
              try
              long wakeUpTime = 600 * 1000;
              Thread.currentThread().sleep(wakeUpTime);
              System.out.println(new Date().toString() + " SimpleTimer Yawn
              ............ Yawn ............");
              catch(InterruptedException ie){}
              private static boolean timerIsRunning = false;
              public void init()
              if(! timerIsRunning)
              Thread sleepy = new Thread(new Sleepy());
              sleepy.start();
              timerIsRunning = true;
              public void doGet(HttpServletRequest request,
              HttpServletResponse response)
              throws IOException, ServletException
              doPost(request, response);
              public void doPost(HttpServletRequest request,
              HttpServletResponse response)
              throws IOException, ServletException
              OutputStream os = response.getOutputStream();
              os.write("look at your std out!!!".getBytes());
              os.flush();
              os.close();
              deploy properties in weblogic.properties
              weblogic.httpd.register.simpletimer=com.cysive.test.SimpleTimerServlet
              weblogic.system.startupClass.servletSimpleTimer=weblogic.servlet.utils.Servl
              etStartup
              weblogic.system.startupArgs.servletSimpleTimer=servlet=simpletimer
              

  • Thread Pool Problem

    Hi,
    I amhaving problem with a thread pooling my code once allocates a thread to a user then never is able to find that it is idle. the code is some what like this.
    public class foo extends Thread{
    pubblic void setPrimeData(Hashtable data){
    //sets the primary data
    run()
    this.isrunning = true;
    //does something
    this.isrunning= false;
    }

    You cannot restart a Thread. Once it has run, it cannot be reused. If you want to hand new tasks to threads in a pool, device some means by which you can hand a running (started) thread a new Runnable to execute in its run() method.
    Chuck

  • Weblogic 10 jsp compliation thread block problem

    hi
    i am using weblogic 10 and jdk1.5.
    My application is deployed in ear format, with 2 wars, and 20 ejbs.
    The ear works ok with weblogic 8.1.
    In the application , one war passes the request to another war, that's the workflow....
    Now when the request is passed on the second war, a jsp is supposed to open....but the application get stuck there.
    The call is like this in a servlet....
         reqDisp = req.getRequestDispatcher("/newIndex.jsp");
    reqDisp.forward(req, res);
    The new index jsp is not opened....there is no problem with it it comiples ok....i check with weblogic appc...and it is working on weblogic 8.1.
    when i stop the server...the log gives me following exception info.
    "ExecuteThread: '12' for queue: 'default'" daemon prio=6 tid=0x2b8edad0 nid=0xc1
    0 in Object.wait() [0x2da1e000..0x2da1fb64]
    at java.lang.Object.wait(Native Method)
    - waiting on <0x07f94608> (a javelin.client.JobWaiter)
    at java.lang.Object.wait(Object.java:474)
    at javelin.client.JobWaiter.blockUntilFinished(JobWaiter.java:45)
    - locked <0x07f94608> (a javelin.client.JobWaiter)
    at javelin.client.ClientUtilsImpl.build(ClientUtilsImpl.java:838)
    at weblogic.servlet.jsp.JavelinxJSPStub.compilePage(JavelinxJSPStub.java:248)
    at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:200)
    at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:164)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:235)
    - locked <0x07ef8220> (a weblogic.servlet.jsp.JavelinxJSPStub)
    at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:391)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:309)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
    at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:503)
    at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:245)
    at LCDisplayController.handleProcessing(Unknown Source)
    at DisplayControllerServlet.doPost(Unknown Source)
    at DisplayControllerServlet.doGet(Unknown Source) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
    at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:503)
    at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:245)
    at com.orbitech.workflow.servlet.WFAppListController.openWorkitem(WFAppListController.java:793)
    at com.orbitech.workflow.servlet.WFAppListController.processRequest(WFAppListController.java:102)
    at com.orbitech.workflow.servlet.WFAppController.doProcessRequest(WFAppController.java:97)
    at com.orbitech.workflow.servlet.WFAppController.doGet(WFAppController.java:64) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
    i think the there is thread blocking and the jsp is not getting compiled or smthing....
    i am unable to understnd the exception....
    any help, suggestion ? thanks in advance.

    We are using jBPM and Hibernate in our application which runs fine on other java application servers. On Weblogic we were getting an error:
    org.hibernate.HibernateException: Errors in named queries: GraphSession...........
    By adding:
    <container-descriptor>
    <prefer-web-inf-classes>true</prefer-web-inf-classes>
    </container-descriptor>
    to our weblogic.xml, Weblogic used our Hibernate3 and antl-2.7.6 .jar files which resolved this issue but created multiple CompilationException errors in many .jsp's. (as follows)
    Error 500--Internal Server Error
    weblogic.servlet.jsp.CompilationException: Failed to compile JSP /WEB-INF/jsp/struts/dashboards/portfolio_chart.jsp
    portfolio_chart.jsp:1:1: The validator class: "org.apache.taglibs.standard.tlv.JstlCoreTLV" has failed with the following exception: "java.lang.ClassCastException: weblogic.xml.jaxp.RegistrySAXParserFactory".
    <%@ taglib uri="/jstl-core" prefix="c" %>
    ^---------------------------------------^
    portfolio_chart.jsp:1:1: The validator class: "com.primavera.pvweb.taglib.JSMessageTagLibraryValidator" has failed with the following exception: "java.lang.ClassCastException: weblogic.xml.jaxp.RegistrySAXParserFactory".
    <%@ taglib uri="/jstl-core" prefix="c" %>
    ^---------------------------------------^
         at weblogic.servlet.jsp.JavelinxJSPStub.compilePage(JavelinxJSPStub.java:298)
         at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:216)
         at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:165)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:235)
         at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:394)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:309)
    Is this a Weblogic bug ?

  • Destroy problem!

    I have a Java program that runtime exec's several other Java
    programs. I'm looking for a
    way to destroy the java process. I try to call destroy method but it doesn't work, the process continue executing.
    public String start() {
    rt = Runtime.getRuntime();
    try {
    processo = rt.exec("cmd /K start java StartELAB");
    catch (Exception ex) {
    ex.printStackTrace();
    return "";
    public String stop {
    int i = 0;
    if(processo != null) {
    try {
    processoElab.destroy();
    catch (Exception ex) {
    ex.printStackTrace();
    //StartELAB doesn't stop.
    Help me!!!!!

    One possible reason for the problem is that the windows shell processor (CMD) always ask "Are you sure?" and wait for an input when interrupted (try running a batch file or a cmd command and hit "Ctrl-C"). So the destroy may work but CMD is asking the stupid question and waiting for input. You can try and verify it by running some other CMD command beside java.
    One possible solution is to run the JVM directly without using CMD.
    Yair.

  • Thread suspension problem

    I have a swing problem, which needs some threading code, but I barely understand it.
    My text field components change the underlying data when the focus is lost. When I click on a different tab in the JTabbedPane while editing a field, at the time the ChangeListener runs, the focus is not lost, so data for the input field is not updated. I tried the following to wait for one of the new tab pane components to be shown, but it does not work.
    class TabFocusListener implements ComponentListener
         private Component comp;
         public TabFocusListener(Component comp)
              this.comp = comp;
              comp.addComponentListener(this);
              try
                   // prg. gets the lock for this object and waits until comp. shown
                   synchronized(this) { wait(10000); }
              catch(InterruptedException ex)
         public void componentShown(ComponentEvent e)
              comp.removeComponentListener(this);
              // frees prg. thread that holds the lock for this object
              notifyAll();
         public void componentHidden(ComponentEvent e){}
         public void componentMoved(ComponentEvent e){}
         public void componentResized(ComponentEvent e){}
    }

    There's a Swing forum for Swing problems. Those guys probably have a solution since they do Swing all day.
    You're waiting/notifying on different objects. "this" refers to the current object. If two different thread call the constructor then there will be two different objects ("this").
    It's also a very bad idea to put a wait inside a constructor. See Brian Goetz's article here: http://www-128.ibm.com/developerworks/java/library/j-jtp0618.html
    You cannot use the object until it is fully constructed.

  • Thread Concurrency problem

    Hello
    i have an application where i have about 6 threads....I have each of this thread working independently ..i.e each thread has its publis static main method.....they are continuously running..... and they are working correctly.... but the problem is that i have run each thread explicitly....
    But now i want to combine all these threads into one thread so that when i run my java application all these threads will start running.....I tried doing it but the problem is that the first thread itself runs...the other threads do not run...... how do i do this????
    The code of the program where i clubbed the threads is
    public class MainThread
    public static void main(String arg[])
    NewThread n= new NewThread() ;
    System.out.println("in psvm") ;
    class NewThread extends Thread
    String name; // name of thread
    Thread t;
    NewThread()
    System.out.println("in newthread") ;
    SMSSendThread sms=new SMSSendThread() ;
    UsernameThread user=new UsernameThread() ;
    user.start() ;
    SendInbox inbox=new SendInbox() ;
    inbox.start() ;
    DeleteSMS delete=new DeleteSMS() ;
    delete.start();
    My start method of each of these thread contains ie.deleteSMS,SendInbox
    public void start()
    HashSet<Socket> clients = new HashSet<Socket>() ;
    try
    Boolean listening=true ;
    ServerSocket ss=new ServerSocket(2345) ;
    Socket socket=new Socket() ;
    int id=0;
    while(listening)
    System.out.println("Detecting Client please Wait in send thread:=") ;
    socket = ss.accept();
    clients.add(socket);
    System.out.println("clients display:="+clients) ;
    if(clients.contains(socket))
    InetAddress clientIP=socket.getInetAddress() ;
    System.out.println("the ip addrss of the client:="+clientIP) ;
    new ConnectionHandlerdelete(socket).start() ;
    The problem is that only the Username thread exceutes priopely the other two are not running!!!!

    Then why are the other threads not runningIf that is your code you are mistaken about this.
    > the newthread class runs as it is supposed to
    The newthread class constructor runs as it is supposed to , and it starts the other threads. You never call start on it so it never executes its run() method. It doesn't even appear to have a run() method.
    So either this is not your real code or your observations are mistaken.

Maybe you are looking for

  • How can  i set a image dinamically in a image component (ADF Mobile)?

    Hello everybody, I have to consume a rest service and get a url. This url is redirected to one image. After reading this image, how can i set he in a adf mobile image component?

  • Nokia PC Suite 6.86.9.0 and change default path

    Hi, Does anybody know how to change the default paths for "File Manager", "Contacts" and "Messages"? When entering those parts of PC Suite it automatically tries to open C:\Program Files\Nokia\Nokia PC Suite 6 folder (installation folder) but in my c

  • Scanning from Photosmart 4580 to Macbook Pro

    Hi, whilst I can print documents from the Mac I cannot scan from the Photosmart to the Mac. On System Preferences under Printers and Scanners there is no scan option. Can you help please? Thanks

  • [X300] Mouse Wheel Scroll Lines Setting does not stick

    I often use an external mouse (no additional driver needed). After every reboot, the setting "Mouse Wheel Scroll Lines" in Control-Panel -> Mouse -> Wheel is reset to 1 (I am using Vista). This is really annoying because it slows down scrolling extre

  • Render faster on Intel or G5?

    I have a 5 minute project with tons of stuff going on inside it. Everything is finally rendered (after 5 hours of render time). Now I'm trying to export it to a DVD using both the "Export to QT" option and the Compressor option in separate instances.