Start Thread method behaviour

I'm using Oracle 10
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining optionsI created two Java classes and a wrapper procedure.
1. The first class timeOutSAPEntry has a delay caused by sleep method of 10 sec. then updates a row in table sap_entry.
2. The second class createMonitorSAPEntry creates an instance of timeOutSAPEntry, call start() method and ends.
3. And the wrapper procedure just calls createMonitorSAPEntry.
My problem: when I call the wrapper procedure, it hangs for 10 sec (consequence of sleep method). But, I expected that the thread could be created, started and then the control returns to procedure and finishes immediatelly. You can see in the execution below the sysdate before and after the procedure call.
Is there any solution? I would like the same behaviour of others JVM, where the main thread continues the execution and not hangs out waiting for the started thread.
create or replace
       and compile java source named "timeOutSAPEntry"
as
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class timeOutSAPEntry
    extends Thread{
    public void run(){
        try{
             this.sleep(10000);
             Connection conn =
                    DriverManager.getConnection("jdbc:default:connection:");
             PreparedStatement  st = conn.prepareStatement("update cmforna.sap_entry set status = 'Failed' where Status = 'Sent'");
             st.executeUpdate();
             st.close();
             conn.commit();
             conn.close();      
        }catch(Exception e){
            e.printStackTrace();
create or replace
       and compile java source named "createMonitorSAPEntry"
as
public class createMonitorSAPEntry{
   public static void create(){
        timeOutSAPEntry to = new timeOutSAPEntry();
        to.start();
create or replace procedure create_monitor_post
as
language java name 'createMonitorSAPEntry.create()';
SQL> insert into sap_entry
  2  (id, posted_on, status)
  3  values
  4  (6, sysdate, 'Sent');
1 row created.
SQL>
SQL> commit;
Commit complete.
SQL>
SQL> select to_char(sysdate, 'hh24:mi:ss') Before_Time from dual;
BEFORE_T
16:27:04
SQL>
SQL> exec create_monitor_post;
PL/SQL procedure successfully completed.
SQL>
SQL> select to_char(sysdate, 'hh24:mi:ss') After_Time from dual;
AFTER_TI
16:27:14
SQL> Many tks,
Miguel

Add a KeyAdapter like this:
addKeyListener(new KeyAdapter() {
  public void keyPressed(KeyEvent ke) {
    int key = ke.getKeyCode();
    if (key == KeyEvent.VK_LEFT) x1--;
    if (key == KeyEvent.VK_RIGHT) x1++;
});*Note that I added this just after the bouncing = true; ... which is on about line 33.
**Note that you will need to click in the Applet before the keys will function.
***Note that you will also likely want to slow down the balls.
~Bill

Similar Messages

  • HOW DO I START THREADS ALL AT ONCE? please help!

    HI! I was just wondering if anybody knew how to start threads all at once. There is the treadgroup stuff but the only method I see there is threadgroup.resume I would like something analogous to threadgroup.start
    any ideas?
    thanks,
    - cunduro

    I don't think you can start all threads at the same time. If what you need is to have all threads ready before they begin doing their job, in the run method you can call a method that waits on some object and when all threads are created (and running and waiting on the object) do a notifyAll(). In that moment all threads will resume working.

  • Starting threads in constructors

    Hi,
    This is kind of a general question. I have a class which initializes a thread within a constructor. e.g.,
    Class A {
             //Initialize thread prerequisites
            String name;
             Thread th;
           classConstructor(String threadName){
                    name = threadName;
                    th = new Thread(this, name);
                    System.out.println( "New Thread: " +th);          
                    th.start() ;
    }Is this the right way of using threads? Or should threads be started from the main method? What are the merits/demerits in these two approaches?
    Thanks!

    You can start threads from anywhere. After all, you're just creating another Java object and calling the start method on it.
    However, there are places where you shouldn't start threads. Unfortunately, in constructors of non-final classes is one of those places. And here's why...
    If you subclass your class, the subclass constructor will begin by calling one of the constructors in your class (either implicitly or explicitly). In this case, your constructor will create and begin a thread. That thread could potentially call methods on this new object instance (especially as in your case you have passed this to the thread, so it looks likely that it will). The problem is, because we're talking about threads, the thread might call the methods on your class before your constructor or the subclass constructor has completed, and you would therefore be calling methods on an incomplete object which might cause issues.
    For example:
    public abstract class A {
      public A() {
        // create and start thread here
      public abstract int getSomething();
    public class B extends A {
      private static int something;
      public B() {
        // implicitly calls A()
        something = 1;
      public int getSomething() {
        return something;
    }Now, if the thread you started calls getSomething(), the return value might be 0, or it might be 1, depending on how the thread executes in relation to the original thread which is executing the constructors.

  • Error starting thread: Not enough storage is available to process...

    Hi all,
    We are seeing server going down frequently with below exception:
    [ERROR][thread ] Failed to start new thread
    [2010-04-08 14:36:54,046][ERROR][com.astrazeneca.portal.rss.ContentTransformer] - Error processing item:null
    ; SystemID: http://beaa.astrazeneca.net:10002/NewsBroker/resources/newsToRss.xsl; Line#: 21; Column#: 128
    javax.xml.transform.TransformerException: java.lang.Error: Error starting thread: Not enough storage is available to process this command.
         at org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(ExtensionHandlerJavaPackage.java:403)
         at org.apache.xalan.extensions.ExtensionHandlerJavaPackage.callFunction(ExtensionHandlerJavaPackage.java:426)
         at org.apache.xalan.extensions.ExtensionsTable.extFunction(ExtensionsTable.java:220)
         at org.apache.xalan.transformer.TransformerImpl.extFunction(TransformerImpl.java:437)
         at org.apache.xpath.functions.FuncExtFunction.execute(FuncExtFunction.java:199)
         at org.apache.xpath.XPath.execute(XPath.java:268)
         at org.apache.xalan.templates.ElemVariable.getValue(ElemVariable.java:279)
         at org.apache.xalan.templates.ElemVariable.execute(ElemVariable.java:247)
    I have a weblogic support SR open and they suggested to add -XXtlaSize and -XXlargeObjectLimit to our JVM parameter. With these parameters, we are getting below error in Windows frequently:
    Reporting queued error: faulting application java.exe, version 1.5.0.11, faulting module jvm.dll, version 27.3.1.1, fault address 0x0014b442.
    I have seen few threads on Sun forum, but answer was not posted there. Details of our environment are as below:-
    JVM : JROCKIT 1.5.0.11
    OS : Windows 2003
    Application Server : Weblogic 10
    Any inputs or pointers will be highly appreciated as this is a bit urgent for me...
    Thanks & Regards,
    Sanjeev

    Hi Henrik,
    I am running Weblogic with below parameters now:
    -Xnohup -Xms:1536m -Xmx:1536m -XXtlaSize:min=32k,preferred=768k -XXlargeObjectLimit:32K
    Weblogic crashed again with below dump:
    ===== BEGIN DUMP =============================================================
    JRockit dump produced after 0 days, 07:17:18 on Fri May 07 15:26:16 2010
    Additional information is available in:
    E:\PortalLIVDomaina\jrockit.5772.dump
    E:\PortalLIVDomaina\jrockit.5772.mdmp
    If you see this dump, please open a support case with BEA and
    supply as much information as you can on your system setup and
    the program you were running. You can also search for solutions
    to your problem at http://forums.bea.com in
    the forum jrockit.developer.interest.general.
    Error Message: Illegal memory access. [54]
    Exception Rec: EXCEPTION_ACCESS_VIOLATION (c0000005) at 0x005148AF - memory at 0x00000000 could not be written.
    Minidump : Wrote mdmp. Size is 1406MB
    SafeDllMode : -1
    Version : BEA JRockit(R) R27.3.1-1_CR344434-89345-1.5.0_11-20070925-1628-windows-ia32
    GC Strategy : Mode: throughput. Currently using strategy: genparpar
    GC Status : OC currently running, in phase: sweeping. This is OC#3000.
    : YC is not running. Last finished YC was YC#9937.
    OC History : Strategy genparpar was used for OC#1.
    : Strategy singleparpar was used for OC#2.
    : Strategy genparpar was used for OC#3 to OC#3000.
    YC History : Ran 11 YCs before OC#2996.
    : Ran 18 YCs before OC#2997.
    : Ran 11 YCs before OC#2998.
    : Ran 8 YCs before OC#2999.
    : Ran 1 YCs before OC#3000.
    Heap : 0x00900000 - 0x60900000
    Compaction : 0x06900000 - 0x0C900000
    Could you please provide some input on this?
    Thanks,
    Sanjeev

  • Starting threads

    Hello all.
    I'd like to ask a simple question regarding new threads creation.
    I need to create a service that opens a new ServerSocket and keeps listening to it. When a new connection arrives, it should use a separated thread to handle the incoming connection. Quite like a HTTP Server.
    I've read that you can't start new threads in the EJB container; so I got confused: where can I start threads? Or how? Can you please explain? Please, I need help with this and can use any pointer of where to look for an answer.
    Thanks a lot.
    Leo.

    I believe you can set an option for oc4j to enable threads I think the option is -useThreads. You can then launch your socketserver from a servlet if you want.
    Not sure if this is good practice or not, but I have heard of people doing it.

  • [svn:bz-trunk] 20471: Changed visibility of start/ stopEndpoints methods from private to protected, so subclasses can override them.

    Revision: 20471
    Revision: 20471
    Author:   [email protected]
    Date:     2011-02-25 06:54:09 -0800 (Fri, 25 Feb 2011)
    Log Message:
    Changed visibility of start/stopEndpoints methods from private to protected, so subclasses can override them.
    Modified Paths:
        blazeds/trunk/modules/core/src/flex/messaging/MessageBroker.java

    Remember that Arch Arm is a different distribution, but we try to bend the rules and provide limited support for them.  This may or may not be unique to Arch Arm, so you might try asking on their forums as well.

  • Joining a Timer started thread

    Given a piece of code that uses a Timer to start a TimerTask, can the main thread get at the timer-started Thread so it can join() on it?

    thrice wrote:
    kajbj wrote:
    @Op.
    Why did you create a new Thread? Um, I'm not sure if you mean "thread" as in a new thread of Java code, or "thread" as in new topic on this forum!I meant thread as in topic.
    >
    I created new threads in my Java code because I need to get about 50 separate pieces of work done as concurrently as the hardware will allow, while still letting the main thread get work done.
    I created a separate topic in this forum because this is a specific question to which I'd like a specific answer!
    @All others. Please continue the discussion in the new thread [http://forums.sun.com/thread.jspa?threadID=5344116]
    Um, no, please answer this simple question in this thread! I don't know if join()ing to a Timer-started Thread object is the way to solve my overall problem. I suspect it isn't, and your suggestion to use a CountDownLatch reinforces that suspicion.A Timer is single threaded. It will not start 50 threads even if you have 50 timer tasks.
    >
    For my Java education, I'd like to know if I can join() to a Timer-started thread, and if so, how do I do it?See above.

  • MaterialMaster_CreateIDOC Cannot start thread

    I am using the Material_Master AOI template with data services I wanted to loop through the IDOC for each plant starting with our main plant then as we loop material would be pushed (extended) to the other plants. When I looped the second time I go the error below. It appears because the connection is already opened for the IDOC another cannot thread be created. Can I close the connection when each plant is pushed and then re-open for the next plant?
    7036       7160       SYS-050703         9/20/2011 2:47:24 PM    |Session Job_P2CMM01_Res_Material_Master|Work flow WF_P2CMM01_Res_MaterialMaster_GenerateIDOC|Data flow DF_P2CMM01_Res_MaterialMaster_CreateIDOC
    7036       7160       SYS-050703         9/20/2011 2:47:24 PM    Cannot start thread.

    Tasks are meant to be run in the context of a JavaFX application, like in the example below:
    import javafx.application.Application;
    import javafx.concurrent.Task;
    import javafx.scene.Scene;
    import javafx.scene.layout.StackPane;
    import javafx.scene.paint.Color;
    import javafx.stage.Stage;
    import java.io.IOException;
    public class TaskApp extends Application {
      public static void main(String[] args) { launch(args); }
      @Override public void start(final Stage stage) throws IOException {
        //create task object
        Task<Integer> task = new Task<Integer>(){
          @Override
          protected Integer call() throws Exception{
            System.out.println("Background task started...");
            int iterations;
            for(iterations = 0; iterations < 10000; iterations++){
              if(isCancelled()){
                break;
              System.out.println("Iteration " + iterations);
              Thread.sleep(3000);
            return iterations;
        //start the background task
        Thread th = new Thread(task);
        th.setDaemon(true);
        System.out.println("Starting background task...");
        th.start();
        stage.setScene(new Scene(new StackPane(), 200, 100, Color.BLANCHEDALMOND));
        stage.show();
    }Also your code was setting the task thread as a daemon thread. The Java Virtual Machine exits when the only threads running are all daemon threads. So once your main routine finished (which would be really quickly), the program would just exit without doing anything much. Note that, in your example, even if you made the Task thread a non-daemon thread, it still doesn't work (likely because the Task class has some reliance on the JavaFX system being initialized). For your simple background process you could skip Task and just use a Runnable or a Callable (which doesn't require JavaFX and hence would work in a non-daemon thread invoked from main), but I guess it's just an experiment.

  • Return of thread starting new method

    hi,
    I have an application that runs a thread pool, each thread builds up a linklist. what I need to know is that I Need to get this linklist only when the thread is done and pass it to another method in another object where all of these linklists are kept.
    How do I do this, I dont have a huge knowledge on threads :(
    I believe I can add this new objective ( to keep all the linklists ) to be run in the same thread pool as well or should I make a new seperate thread to run it.
    Other thing is I believe I can synchronize that method so it waits until one link list is finished, but is this an efficient way I mean the threads in my thread pool changes fast, so is it ok to make the method synchronized. I mean does that decrease the performance, say each thread takes about 1 sec to finish...
    Thank you.

    thanks
    each thread is for obtaining information from network
    stream which takes up time. one thread handles one
    IP. If I use only 1 thread It takes a hell of a long
    time.. I said 1 sec for 1 thread as just a measure
    but practically it takes more than that ...Okay. I just wanted to make sure you had a good reason to use multiple threads, rather than thinking that multithreading a CPU-intensive operation would magically make it go faster.
    I'll try the join method, the main thread which
    starts the thread pool execution waits until
    everything is done.That can work, depending on your requirements. If you want the main thread to stop and do nothing until ALL the other threads are done, that's fine. But if you want something to happen as soon as each thread finishes, join is not a good way to go.
    so is it OK if I run the linklist
    processing method in the mainthread's stack or shall
    I use a thread in the thread pool for that..I don't understand enough about what you're trying to do to answer that.

  • WLS5.1 SP8 problem : weblogic does not start anymore : method getClassLoadNotify()Lweblogic/boot/ClassLoadNotify; not found

    Hello,
    I currently have a problem with the EJBException which does not give the
    client the getCausedBy() Exception. I d' like to try the 5.1 sp8 to see if
    the bug is fix.
    Unfortunately, after having installed the sp8, my WLS 5.1 does not start
    anymore : I get an invocationTargetException.
    Does anyone have a clue ?
    Best Regards.
    dom
    The WebLogic Server did not start up properly.
    Exception raised: java.lang.reflect.InvocationTargetException
    java.lang.reflect.InvocationTargetException: java.lang.NoSuchMethodError:
    weblogic.boot.ServerClassLoader: method
    getClassLoadNotify()Lweblogic/boot/ClassLoadNotify; not found
    at
    weblogic.utils.classloaders.GenericClassLoader.<init>(GenericClassLoader.jav
    a:141)
    at
    weblogic.utils.classloaders.GenericClassLoader.<init>(GenericClassLoader.jav
    a:113)
    at
    weblogic.utils.classloaders.GenericClassLoader.<init>(GenericClassLoader.jav
    a:105)
    at
    weblogic.utils.classloaders.RecursiveReloadOnModifyClassLoader.<init>(Recurs
    iveReloadOnModifyClassLoader.java:53)
    at
    weblogic.utils.classloaders.RecursiveReloadOnModifyClassLoader$SingleSlave.<
    init>(RecursiveReloadOnModifyClassLoader.java:149)
    at
    weblogic.servlet.internal.ServletContextImpl.setClassLoader(ServletContextIm
    pl.java:1571)
    at
    weblogic.servlet.internal.ServletContextImpl.<init>(ServletContextImpl.java:
    539)
    at
    weblogic.t3.srvr.HttpServer.initServletContexts(HttpServer.java:523)
    at weblogic.t3.srvr.HttpServer.start(HttpServer.java:418)
    at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java:1312)
    at weblogic.t3.srvr.T3Srvr.main(T3Srvr.java:827)
    at java.lang.reflect.Method.invoke(Native Method)
    at weblogic.Server.startServerDynamically(Server.java:99)
    at weblogic.Server.main(Server.java:65)
    at weblogic.Server.main(Server.java:55)
    at weblogic.NTServiceHelper.run(NTServiceHelper.java:19)
    at java.lang.Thread.run(Thread.java:479)
    java.lang.NoSuchMethodError: weblogic.boot.ServerClassLoader: method
    getClassLoadNotify()Lweblogic/boot/ClassLoadNotify; not found
    at
    weblogic.utils.classloaders.GenericClassLoader.<init>(GenericClassLoader.jav
    a:141)
    at
    weblogic.utils.classloaders.GenericClassLoader.<init>(GenericClassLoader.jav
    a:113)
    at
    weblogic.utils.classloaders.GenericClassLoader.<init>(GenericClassLoader.jav
    a:105)
    at
    weblogic.utils.classloaders.RecursiveReloadOnModifyClassLoader.<init>(Recurs
    iveReloadOnModifyClassLoader.java:53)
    at
    weblogic.utils.classloaders.RecursiveReloadOnModifyClassLoader$SingleSlave.<
    init>(RecursiveReloadOnModifyClassLoader.java:149)
    at
    weblogic.servlet.internal.ServletContextImpl.setClassLoader(ServletContextIm
    pl.java:1571)
    at
    weblogic.servlet.internal.ServletContextImpl.<init>(ServletContextImpl.java:
    539)
    at
    weblogic.t3.srvr.HttpServer.initServletContexts(HttpServer.java:523)
    at weblogic.t3.srvr.HttpServer.start(HttpServer.java:418)
    at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java:1312)
    at weblogic.t3.srvr.T3Srvr.main(T3Srvr.java:827)
    at java.lang.reflect.Method.invoke(Native Method)
    at weblogic.Server.startServerDynamically(Server.java:99)
    at weblogic.Server.main(Server.java:65)
    at weblogic.Server.main(Server.java:55)
    at weblogic.NTServiceHelper.run(NTServiceHelper.java:19)
    at java.lang.Thread.run(Thread.java:479)
    tel 02 38 64 37 95
    mailto:[email protected]

    Well... I've made a big classpath mistake.
    It works indeed.
    dom
    "Dominique Jean-Prost" <[email protected]> a écrit dans le
    message news: [email protected]...
    Hello,
    I currently have a problem with the EJBException which does not give the
    client the getCausedBy() Exception. I d' like to try the 5.1 sp8 to see if
    the bug is fix.
    Unfortunately, after having installed the sp8, my WLS 5.1 does not start
    anymore : I get an invocationTargetException.
    Does anyone have a clue ?
    Best Regards.
    dom
    The WebLogic Server did not start up properly.
    Exception raised: java.lang.reflect.InvocationTargetException
    java.lang.reflect.InvocationTargetException: java.lang.NoSuchMethodError:
    weblogic.boot.ServerClassLoader: method
    getClassLoadNotify()Lweblogic/boot/ClassLoadNotify; not found
    at
    weblogic.utils.classloaders.GenericClassLoader.<init>(GenericClassLoader.jav
    a:141)
    at
    weblogic.utils.classloaders.GenericClassLoader.<init>(GenericClassLoader.jav
    a:113)
    at
    weblogic.utils.classloaders.GenericClassLoader.<init>(GenericClassLoader.jav
    a:105)
    at
    weblogic.utils.classloaders.RecursiveReloadOnModifyClassLoader.<init>(Recurs
    iveReloadOnModifyClassLoader.java:53)
    at
    weblogic.utils.classloaders.RecursiveReloadOnModifyClassLoader$SingleSlave.<
    init>(RecursiveReloadOnModifyClassLoader.java:149)
    at
    weblogic.servlet.internal.ServletContextImpl.setClassLoader(ServletContextIm
    pl.java:1571)
    at
    weblogic.servlet.internal.ServletContextImpl.<init>(ServletContextImpl.java:
    539)
    at
    weblogic.t3.srvr.HttpServer.initServletContexts(HttpServer.java:523)
    at weblogic.t3.srvr.HttpServer.start(HttpServer.java:418)
    at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java:1312)
    at weblogic.t3.srvr.T3Srvr.main(T3Srvr.java:827)
    at java.lang.reflect.Method.invoke(Native Method)
    at weblogic.Server.startServerDynamically(Server.java:99)
    at weblogic.Server.main(Server.java:65)
    at weblogic.Server.main(Server.java:55)
    at weblogic.NTServiceHelper.run(NTServiceHelper.java:19)
    at java.lang.Thread.run(Thread.java:479)
    java.lang.NoSuchMethodError: weblogic.boot.ServerClassLoader: method
    getClassLoadNotify()Lweblogic/boot/ClassLoadNotify; not found
    at
    weblogic.utils.classloaders.GenericClassLoader.<init>(GenericClassLoader.jav
    a:141)
    at
    weblogic.utils.classloaders.GenericClassLoader.<init>(GenericClassLoader.jav
    a:113)
    at
    weblogic.utils.classloaders.GenericClassLoader.<init>(GenericClassLoader.jav
    a:105)
    at
    weblogic.utils.classloaders.RecursiveReloadOnModifyClassLoader.<init>(Recurs
    iveReloadOnModifyClassLoader.java:53)
    at
    weblogic.utils.classloaders.RecursiveReloadOnModifyClassLoader$SingleSlave.<
    init>(RecursiveReloadOnModifyClassLoader.java:149)
    at
    weblogic.servlet.internal.ServletContextImpl.setClassLoader(ServletContextIm
    pl.java:1571)
    at
    weblogic.servlet.internal.ServletContextImpl.<init>(ServletContextImpl.java:
    539)
    at
    weblogic.t3.srvr.HttpServer.initServletContexts(HttpServer.java:523)
    at weblogic.t3.srvr.HttpServer.start(HttpServer.java:418)
    at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java:1312)
    at weblogic.t3.srvr.T3Srvr.main(T3Srvr.java:827)
    at java.lang.reflect.Method.invoke(Native Method)
    at weblogic.Server.startServerDynamically(Server.java:99)
    at weblogic.Server.main(Server.java:65)
    at weblogic.Server.main(Server.java:55)
    at weblogic.NTServiceHelper.run(NTServiceHelper.java:19)
    at java.lang.Thread.run(Thread.java:479)
    tel 02 38 64 37 95
    mailto:[email protected]

  • Wish to prevent application starting threads

    Hi,
    I wish to prevent my standalone java application from executing threads.
    I ensure the permission,      java.lang.RuntimePermission "modifyThreadGroup" is not in the policy file.
    According to http://java.sun.com/j2se/1.4.2/docs/guide/security/permissions.html, I believe the application should not be able to instantiate new thread objects.
    To test it, I run the code:
              Runnable tonyRunnable = new Runnable() {
                   public void run() {
                        System.out.println("tony says it's cool!");
              Thread t = new Thread(tonyRunnable);
              t.start();
              t.join();And it runs. I expect a security exception but don't get it. I am 100% confident my application has a security manager and policy file.
    Any ideas?
    Thanks.

    You're not doing anything with ThreadGroups in the code above. The modifyThreadGroup target of RuntimePermission is for allowing:
    "modification of thread groups, e.g., via calls to ThreadGroup destroy, getParent, resume, setDaemon, setMaxPriority, stop, and suspend methods"
    There is no way to prevent an application from creating and starting its own threads.

  • Starting thread numerous times

    hi, i got the following code:
    public class TestRunnerThread
      extends Thread
      private ThreadCheck test = null;
      public TestRunnerThread()
        test = new ThreadCheck();  // doesn't work - see run method.
      public static void main(
          String[] args_)
        TestRunnerThread runner = new TestRunnerThread();
        runner.start();
      public void run()
        while (true)
          try
            // ::NOTE:: thread only works with new instance - starting old thread
            // doesn't work anymore as soon as the thread leaves it's run method.
            // test = new ThreadCheck();  // this works
            test.start();
            System.out.println("waiting till join...alive:" + test.isAlive());
            test.join();
            System.out.println("sleep...");
            Thread.sleep(3000);
          catch (InterruptedException e)
            e.printStackTrace();
    public class ThreadCheck
      extends Thread
      boolean tester = false;
      public ThreadCheck()
        tester = true;
      public void run()
        System.out.println("#test:" + tester);
        System.out.println("#..............");
    }the ThreadChecker runs only if more than once if i create a new ThreadChecker object for every loop in the TestRunnerThread run method. although test.isAlive()) returns true even if i initialize the ThreadChecker only once in the TestRunnerThread run method which confuses me. isn't it possible to start the thread again as soon as it left the run method? and if so, why does it still say true for isAlive?
    cheers,
    mischka

    Hi,
    A thread that has terminated can't be re-started.
    /Kaj

  • Deprecated Thread Methods

    My organization has recently come from the Microsoft world into the J2EE world. In .Net, Microsoft has an abort method on threads that is similar to the Java's stop method. Unfortunately, the stop method has been deprecated.
    While I have read the information on why this method is dangerous, I don't understand why the method has been removed. If I have a situation that warrants killing a thread (such as in the case of an application server that hosts other threads of execution), why remove it from the platform? While I agree with Sun's article on seeking out alternative methods, there are still exceptions where a thread just needs to be interrupted so that it can get out of a deadlock, endless loop or blocking I/O.
    Since the stop method is deprecated, is there an equivalent VM call that I can interface from native code?
    I must say that I feel a bit like I'm being mothered by Sun.

    From your comments, you make a strong argument that suggests there's no need for a VM-level stop function.
    This puzzles me because operating systems implement kill methods to terminate rogue processes, yet they remain efficient and manage to keep things clean. Granted, multiple processes don't generally share memory structures but certainly the OS, on their behalf, shares memory structures. I'm puzzled as to why similar desires/features aren't present in the JRE.
    Regardless, short of running multiple JRE instances, each managing just one piece of work, the current deprecated status of the stop method renders Java without the ability to stop something that's gone wild unless the application is specifically pre-programmed to anticipate this behavior. (Of course that's a bit of a catch 22 in and of itself but...)
    There is also a subscription to the notion that my company or company x can write perfect software that never hangs a Java-based application server. I feel that this is impractical -- especially when what businesses ask of IT continues to get more complex.
    At this point perhaps it's fair to reveal the underlying reasons for my up-to-now, hypothetical questions. In my situation, company x is actually Sun. They failed to expose a socket timeout on their implementation of HTTPUrlConnection. I suppose that pretty much removes the luster from the argument that I, or anyone else, can write perfect software when the inventors of Java are themselves, imperfect. Of course, like you said and the JDK documents, the stop method will not abort a blocking socket read anyway (...although there's no reason why it couldn't except for more flawed design decisions...)
    I've certainly investigated alternative packages but I'm just chasing a moving target. HTTPUrlConnection today, class x tomorrow. That's why I was wanting something at the framework level to provide a trap door so that recovery without terminating the JRE is possible.

  • Thread Methods but in Object class, y?

    Why wait, notify, notifyall methods are in object class instead of Thread class?

    thechad wrote:
    It's not clear to me why. Probably it's a historical artefact .. once it was in Object, it's hard to take it out.
    You're question is a fair question it seems to me. Maybe someone will tell you there's a good reason.Yes, there is a very good reason and it's not a historical artifact.
    wait / notify are used for locking in java. For instance, imagine you have a job queue, and you've got a whole bunch of worker threads that are getting jobs from it. What happens when the queue is empty and there are no more jobs? You want to wait for the queue to have more jobs. Then when a new job comes in, you want to notify any thread waiting that it can now proceed.
    In fact, with reference to why isn't this just handled in thread, it is dangerous and wrong to call wait, notify or notifyall on a Thread object... Thread.join calls wait on the thread and thread death calls notifyAll, but API docs don't guarentee this so you should avoid these methods in a Thread object.

  • Threads & Methods

    hi,
    i have question.... when you call a method ... then are you creating a
    new Process........ or in other words : is
    calling a method = creating a new process
    just curious

    answer = no
    A thread represents a flow of execution - when you call a method the same thread is used to run that method. When that method is finished the thread continues from where it was in the calling method.
    I'm surprised you're asking this question given your areas of expertise. Perhaps I've misunderstood what you mean?
    Hope this helps.

Maybe you are looking for

  • Not Found error

    After setting up the test perl script to access our site, I get the following error: "The requested URL /WebObjects/Core.woa/Browse/cfcc.edu was not found on this server." Was our site expired due to the fact we haven't logged in for a while?

  • Help w/compressing movie

    i put to together a movie from a dvd and audio from a cd, its about 2 hours long and the file size is a whopping 20 GB. i'm going to compress it to quicktime, but im wondering if that will screw with the audio, and also how big the file may be. thank

  • A mutilple sources to multiple targets integration interface

    I need to populate multiple target tables based on multiple source tables. Is there a way to do it using ODI? Many thanks, Irina

  • How do you restore your photos icon?

    My photo's icon has disappeared, does anyone know how to get it back?

  • Edit rotation - then time remapping - keyframes for rotation don't sync

    I have some footage that requires quite a bit of rotational correction which worked fine. I then need to slow some of it down. I used time remapping. This resulted in the correct slow motion but the key frames for the rotation editing did not "stretc