Stopping a java thread via PL/SQL

I started a java thread from a stored procedure and I can't seem to kill it unless I drop the DB. Can anyone tell me if there is a way through PL/SQL to kill the thread I started.
Also is there a way to start a thread and advance my PL/SQL block? I can't seem to proceed in my block of code.
Thanks
Any help!

Jack,
I didn't understand pretty much...
couldn't you explain a little bit
better how to do it?
thanks for your attention,
Dan
<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Jack Tsai ([email protected]):
Dan:
Please check the following forum message for your question:
http://technet.oracle.com:89/ubb/Forum88/HTML/001611.html
Jack<HR></BLOCKQUOTE>
null

Similar Messages

  • How to proces the record in Table with multiple threads using Pl/Sql & Java

    I have a table containing millions of records in it; and numbers of records also keep on increasing because of a high speed process populating this table.
    I want to process this table using multiple threads of java. But the condition is that each records should process only once by any of the thread. And after processing I need to delete that record from the table.
    Here is what I am thinking. I will put the code to process the records in PL/SQL procedure and call it by multiple threads of Java to make the processing concurrent.
    Java Thread.1 }
    Java Thread.2 }
    .....................} -------------> PL/SQL Procedure to process and delete Records ------> <<<Table >>>
    Java Thread.n }
    But the problem is how can I restrict a record not to pick by another thread while processing(So it should not processed multiple times) ?
    I am very much familiar with PL/SQL code. Only issue I am facing is How to fetch/process/delete the record only once.
    I can change the structure of table to add any new column if needed.
    Thanks in advance.
    Edited by: abhisheak123 on Aug 2, 2009 11:29 PM

    Check if you can use the bucket logic in your PLSQL code..
    By bucket I mean if you can make multiple buckets of your data to be processed so that each bucket contains the different rows and then call the PLSQL process in parallel.
    Lets say there is a column create_date and processed_flag in your table.
    Your PLSQL code should take 2 parameters start_date and end_date.
    Now if you want to process data say between 01-Jan to 06-Jan, a wrapper program should first create 6 buckets each of one day and then call PLSQL proc in parallel for these 6 different buckets.
    Regards
    Arun

  • How to 'STOP' a running java thread in J2ME?

    Dear All,
    How to 'STOP' a running java thread in J2ME?
    In the middleware viewpoint, for some reasons we have to stopped/destroyed the running threads (we have no information how these applications designed).
    But in J2ME, Thread.destroy() is not implemented. Are there other approaches to solve this problem?
    Thanks in advance!
    Jason

    Hi jason,
    Actually there are no methods like stop() and interrupt() to stop the threads in J2ME which is present in normally J2SE Environment.
    But the interrupt method is introduced in Version 1.1 of the CLDC.
    So, we can handle the thread in two ways.
    a) If it is of single thread, then we can use a boolean variable in the run method to hadle it. so when the particular boolean value is changed , it will come out of the thread.
    for eg:
    public class exampleThread implements Runnable
    public boolean exit = false;
    public void run()
    while(!exit)
    #perform task(coding whatever u needed)
    public void exit()
    exit = true;
    b) If it is of many threads then we can handle using the instance of the current thread using currentThread() method
    for eg:
    public class exampleThread implements Runnable
    public Thread latest = null;
    public Thread restart()
    latest = new Thread(this);
    latest.start();
    public void run()
    Thread thisThread = Thread.currentThread();
    while( latest == thisThread )
    #perform some tasks(coding part);
    public voi d stopAll()
    latest = null;
    while ( latest == thisThread )
    performOperation1();
    if( latest != thisThread )
    break;
    performOperation2();
    Regards,
    Prathesh Santh.

  • Calling pl/sql api through multiple java threads

    Hi All,
    I need to call a pl/sql api from multiple java threads simultaneously and all thread will use same db connection.
    I want to know if all the threads will simultaneously call the pl/sql api then will the local variable inside pl/sql procedure be shared between them or they will get separate instances of variables.
    TIA

    You cannot make multiple parallel client calls over the same Oracle session handle. There is a single non-threaded/non-fibre serialised server process servicing client requests for that session. (physical process on Linux/Unix, thread in the oracle.exe process on Windows).
    Each thread on the client side, needs its very own Oracle session. Thus each thread will have a server process footprint on the server. Which could be problematic if 10 clients each starts 10 threads - as it means a 100 processes on the server are needed to service these client threads.
    Have a look at Overview of OCI Multithreaded Development in the Oracle® Call Interface Programmer's Guide for how to use the threading call interface of the OCI - as oppose to rolling your own where each thread manually needs to deal with is OCI session context.

  • How to stop a daemon Java Thread?

    If I have a thread set as daemon and the main program has already exited, how do I locate the thread to stop it?
    Thanks.

    > As for stopping it you use a socket and send it a message. That of course would require another thread because it is a listener.
    Could you explain me a little bit more this (or send a link)? That is probably what I want to do. I want to open another instance of the program and stop the running thread. (By the way I'm doing this on Windows).
    Daemon thread != unix daemon.
    I'm not actually setting the thread as deamon because I want it as a background task, but because I want the main program to exit after it has started the thread and I want the thread to keep running. I read somewhere that I could do this setting the thread as daemon. But I misunderstood what I read.
    Again, what I want to know if there's a way of running an app that when you press a start button, for example starts a thread that performs some ops. and exits, but the thread is still running, and if you re-open the app and press the stop button it stops the running thread, that is, the instance of the app that created the thread is not the one who's going to stop it.
    I don't necesarily want to do it using threads but that was the way I first thought of.
    Thank you for your reply :)
    Message was edited by:
    daraii

  • Java threads and WinLogon processes taking CPU!

    We are seeing a strange problem. We have a multi-threaded java application
    that is deployed on a Microsoft Windows 2000 server (SP4) with Citrix
    Metaframe XP (Feature release 2). When this application starts, we start to see
    multiple WINLOGON.EXE processes (20 plus) each taking up 1-2% of CPU -
    this raises the CPU usage on the server significantly, impacting performance.
    We have tested with JDK 1.3, 1.4, and 1.5 and see the same issues. If we
    run the java application in a single thread, we dont see the same issue.
    Has any one seen this problem before? Any suggestion on how this can be resolved?
    Thanks in advance!

    Thanks for your replies. This is a Citrix environment where there are 50 plus
    users logged in and there are 50 plus instances of Winlogon.exe always
    running. Most of the time the cpu usage of these processes is 0.
    We tried a multi-threaded program that lists files in a directory every few
    seconds. There are 40 plus servers in the farm that we are deploying this
    application on. We are seeing this problem on only some of the servers.
    If we run a single thread from main(), we dont see the issue. But if we spawn
    10 threads doing the scans periodically, we notice that as soon as all the threads
    start, the WinLogons appear to start to take up CPU. When we stop the java
    program, the WinLogon processes drop in CPU usage.
    Is it possible that Java and WinLogon share some dlls that could be triggering
    the WinLogon processes off?
    We have tried running the single thread and multi-threaded programs around
    same time and the correlation with the winlogons is clearly visible. If we add
    sleep() soon after we start a thread, the winlogons seem to kick in later.

  • Java thread not working in windows 7

    I have a Java app that runs just fine on Windows XP. However, on Windows 7 there is a problem related to a job being done via a Java thread.
    Background: The app spawns a separate job via a Java thread and continues on while the spawned job executes. In other words, 2 things happen at once.
    Problem: On Windows 7, when the app spawns the job, Windows sits and waits for the spawned job to complete before it continues on. In other words, 2 things DO NOT happen at once.
    It's as if Java threading does not work in Windows 7. Any input would be greatly appreciated. Thanks.

    l_sleven wrote:
    Thanks for the input, guys. From now on I'll be sure to include a SSCCE.
    I'm beginning to believe this is actually my ignorance of threading in SWT, and XP was more forgiving than 7.
    I would include a SSCCE, but of the 4 different ways I tried to get this to work I wouldn't know which to include since all failed to fix the problem.
    If you want to identify a link to a web page identifying 'best practices' for SWT threading, that would be great. Be aware though that there's a good chance I've already googled the page.
    A programmer smarter than me once said, "The road to best practices is a bumpy ride".[Concurrency in Swing|http://download.oracle.com/javase/tutorial/uiswing/concurrency/index.html]

  • Use java thread? or Oracle DB scheduler?

    I have a java thread which purge records in a table every 30 seconds. The thread calls a prepared statement which is like "delete from MyTable where status=99"
    can I use DB's scheduled job to do the same thing? I can create a DB schedule, and a job in plsql.
    Thus I can save on DB connections.
    Which one is better in terms of performance?

    SoulTech2012 wrote:
    i personally recommend against PL/SQL if you can manage it
    some will argue that it's okay to couple yourself to a database because you're likely not to change it
    but i've seen enough migrations to know the painConversely I have seen attempts to process data by dragging it across the network in the vain attempt to make the application database agnostic. Which results in orders of magnitude more processing time when the application needs to do anything approaching real volume.

  • Help calling JNI function from a java thread

    I am using the following code to call a JNI fuction from a java thread:
    public class CMSMessageHandler extends MessageHandler{
    static{
    System.loadLibrary("jastb");
    public native int cmsReadIt(ByteBuffer buff);
    private ByteBuffer dirbuf = null;
    /** Creates a new instance of CMSMessageHandler */
    public CMSMessageHandler() {
    // allocate to max size datagram
    dirbuf = ByteBuffer.allocateDirect(65536);
    public void readMessages(){
    /*Thread worker = new Thread(){
    public void run(){*/
    int count;
    while (true){
    try{
    count = cmsReadIt(dirbuf);
    } catch (Exception e){
    e.printStackTrace();
    worker.start();*/
    public static void main(String[] args) {
    CMSMessageHandler handler = new CMSMessageHandler();
    handler.readMessages();
    When I run this main method with the thread commented out, it works great. When I run the main method with the thread, it works great for a while, and then funny things start happening with the native library I am using. My native library uses shared memory, signals, and semaphores. It feels a bit like my java program is stomping on the resources that my native library is using, when a run the java program with a thread.
    Is there something I don't know about calling native code from a thread? Should I be doing something explicitly to protect my native library's shared memory, signals, or semaphores?
    Thanks,
    Lisa.

    Does the library do any initialization when loaded? Does it make a dangerous assumption that the thead calling cmdReadIt will always be the same thread that initially loaded it? Try loading the library in the worker thread instead of in the main thread via the static initializer.Yes. There is a call to another native method cmsOpenIt that does CMS initialization. I put cmsOpenIt as well as the System.loadLibrary("jastb") in the worker thread and I'm still experiencing the same problems.
    Incidently, the mere presence of another Thread in this program does not seem to cause problems. It's only when I run calls to cmsReadIt in a thread that I get into trouble.
    For example, this works fine:
    public class CMSMessageHandler extends MessageHandler{
        public native int cmsReadIt(ByteBuffer buff);
        public ByteBuffer dirbuf = null;
        static {
            System.loadLibrary("jastb");
        public CMSMessageHandler() {
            // allocate to max size datagram
            dirbuf = ByteBuffer.allocateDirect(65536);
        public void readMessages(){
            try{
                int count = 0;
                while (true){
                    count = cmsReadIt(dirbuf);
            } catch (Exception e){
        public static void main(String[] args) {
            CMSMessageHandler handler = new CMSMessageHandler();
            Thread worker = new Thread(){
                public void run(){
                    while (true){
                        try{
                            Thread.currentThread().sleep(1000);
                            System.out.println("sleep thread.");
                        } catch (Exception e){
                            e.printStackTrace();
            worker.start();
            handler.readMessages();  
        }Are there JVM flags that I should experiment with that might help mitigate/diagnose this problem?

  • Question about java threads programming

    Hi
    I have to develop a program where I need to access data from database, but I need to it using multithreading, currently I go sequentially to each database to access data which is slow
    I have a Vector called systemnames, this one has list of all the systems I need to access.
    Here is my current code, some thing like this
    Vector masterVector = new Vector();
    GetData data = new GetData();
    For(int i =0; i < systemnames.size(); i++)
    masterVector.add(data.getData((String)systemnames.get(i));
    public class GetData
    private Vector getData(String ipaddress)
    //process SQL here
    return data;
    how do i convert this to multithread application, so there will be one thread running for each system in vector, this is speed up the process of extracting data and displaying it
    has any one done this kind of program, what are the precautions i need to take care of
    Ashish

    http://www.google.com/search?q=java+threads+tutorial&sourceid=opera&num=0&ie=utf-8&oe=utf-8
    http://java.sun.com/docs/books/tutorial/essential/threads/
    http://www.javaworld.com/javaworld/jw-04-1996/jw-04-threads.html
    http://www.cs.clemson.edu/~cs428/resources/java/tutorial/JTThreads.html
    http://www-106.ibm.com/developerworks/edu/j-dw-javathread-i.html
    When you post code, please use [code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read and prevents accidental markup from array indices like [i].

  • Java.lang.NoClassDefFoundError: oracle/sql/STRUCT after 11g/GF3.1.2 upgrade

    We have recently upgraded all of our servers from:
    Java 1.6.31 to 1.6.32
    and
    Glassfish 3.1.1 to 3.1.2
    We upgraded our development server from Oracle 10g to 11g.
    Our live servers are working fine. Our development server now is spewing out a java.lang.NoClassDefFoundError: oracle/sql/STRUCT error whenever it encounters a servlet or page which uses this class.
    ojdbc14.jar and sdopai.jar were included within the WAR file, and I have tried with them excluded from the WAR file to no avail. We have tried reverting the version of ojdbc.jar on the server to the earlier version, this has made no different.
    Any ideas? The full stack trace is below:
    [#|2012-05-28T16:15:34.950+0100|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=80;_ThreadName=Thread-2;|StandardWrapperValve[EnterDataSS]: PWC1406: Servlet.service() for servlet EnterDataSS threw exception
    java.lang.NoClassDefFoundError: oracle/sql/STRUCT
    at oracle.spatial.geometry.JGeometry.load(JGeometry.java:3097)
    at Bto.Location.LocatorUtils.JavaScriptifySDO(LocatorUtils.java:97)
    at Bto.Chats.Controllers.EnterDataModuleMain.<init>(EnterDataModuleMain.java:136)
    at Bto.Chats.SessionBean.initialiseEdm2(SessionBean.java:348)
    at Bto.Chats.Servlets.Enter.EnterDataSS.processRequest(EnterDataSS.java:36)
    at Bto.Chats.Servlets.ChatsServlet.doGet(ChatsServlet.java:90)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1542)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
    at com.sun.grizzly.http.ajp.AjpProcessorTask.invokeAdapter(AjpProcessorTask.java:135)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)
    Caused by: java.lang.ClassNotFoundException: oracle.sql.STRUCT
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 33 more
    |#]

    >
    Our live servers are working fine. Our development server now is spewing out a java.lang.NoClassDefFoundError: oracle/sql/STRUCT error whenever it encounters a servlet or page which uses this class.
    ojdbc14.jar and sdopai.jar were included within the WAR file, and I have tried with them excluded from the WAR file to no avail. We have tried reverting the version of ojdbc.jar on the server to the earlier version, this has made no different.
    >
    If your code can't find the class then you have the classic NoClassDefFoundError problem you get when any other referenced class can't be located.
    The oracle/sql/STRUCT class is in the ojdbc14.jar, ojdbc5.jar and ojdbc6.jar so if it can't be found then that class is missing from the jar you are using (which you can tell by examining the jar contents) or the jar is missing from the classpath being used.
    As already mentioned you need the Oracle 11 JDBC files to support Java 1.6
    Here is the official Oracle JDBC page that shows the Oracle DB versions supported for each of the JDBC drivers available and also describes the JDBC jars and what JDK versions they support.
    http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#02_01
    >
    Which JDBC drivers support which versions of Javasoft's JDK?
    pre-8i OCI and THIN Drivers - JDK 1.0.x and JDK 1.1.x
    8.1.5 OCI and THIN Drivers - JDK 1.0.x and JDK 1.1.x
    8.1.6SDK THIN Driver - JDK 1.1.x and JDK 1.2.x (aka Java2)
    8.1.6SDK OCI Driver - Only JDK 1.1.x
    8.1.6 OCI and THIN Driver - JDK 1.1.x and JDK 1.2.x
    8.1.7 OCI and THIN Driver - JDK 1.1.x and JDK 1.2.x
    9.0.1 OCI and THIN Driver - JDK 1.1.x, JDK 1.2.x and JDK 1.3.x
    9.2.0 OCI and THIN Driver - JDK 1.1.x, JDK 1.2.x, JDK 1.3.x, and JDK 1.4.x
    10.1.0 OCI and THIN Driver - JDK 1.2.x, JDK 1.3.x, and JDK 1.4.x
    10.2.0 OCI and THIN Driver - JDK 1.2.x, JDK 1.3.x, JDK 1.4.x, and JDK 5.0.x
    11.1.0 OCI and THIN Driver - JDK 1.5.x and JDK 1.6.x
    11.2.0 OCI and THIN Driver - JDK 1.5.x and JDK 1.6.x
    Please note that JDK 1.4 is not supported by the 11 drivers.

  • Problems with java Thread

    I'm reading book "JAVA THREAD" published by OREILLY.
    And on fifth chapter, it gives an example.
    one Thread's two method:
    private boolean done = false;
    public void run()
    while(!done)
    foo();
    public void setDone()
    done = true;
    it says, the run method will be compiled as machine code:
    Begin method run
    load register r1 with memory location 0xff12345
    Label L1:
    Test if register r1 == 1
    If true branch to L2
    Call method foo
    Branch to L1
    Label L2:
    End method run
    setDone method will be compiled like:
    Begin method setDone
    Store 1 into memory location 0xff12345
    End method setDone
    And it says " because Run method will never reload 0xff12345 to register r1(in while loop), so setDone method will never lead to run stop.
    I'm so puzzled with this. I have test this code on windows platform, run method can stop after another Thread call setDone method !.
    but I think "JAVA THREAD" should have error on this, so why ?

    If the book says it will happen like that, then the book is wrong.
    I think what they meant--and what would be correct to say--is that that is an example of what could happen if you don't synchronize all access to the run variable.
    The point is this: Threads can have local copies of variables, that are separate from other threads' local copies and separate from the "master" copy. The spec doesn't define where those local copies live--the implementation can put them anywhere it wants--but the most natural and sensible thing would be to store the local copies in CPU registers, rather than in main mem.
    The example the book gave shows what might happen if that VM stores threads' local copies in registers. There's no guarantee that the problem they described will happen, but it could, so you have to guard against it.
    You guard against it by declaring that shared variable volatile, which requires that the threads use the master copy rather than their local copies, or by synchronizing every access to that thread. Syncing requires reading from the master copy on entering the sync block (or on first access) and writing out to the master copy upon leaving the sync block.

  • Some Java Thread error in Xp (Urgent)

    HI all,
    I am working on a 3 tier software and it is running fine on all machines except one "The XP Machine",
    The problem is when i m going tru http://appserv:13000 it starts executing but in between an error comes that shows that some java thread or null pointer error and execution stops, i have faced similar type of error in WIN 98 but after installing java virtual machine it was sorted.
    but on this perticular machine i have already installed this JVM, but still problem is as it is.
    Please help me to sort this problem,
    Thanks & regards
    Tehzeeb Ahmed

    Tehzeeb,
    this is an Oracle Forms discussion forum. General Java questions are best answered on teh J2EE forum or the JDeveloper forum.
    Btw.: You need to be more specific when describing the problem.
    Frank

  • Java thread that start executing everyday on given time

    Hello
    I need to write an java file using thread
    that can start executing everyday on given time say everyday 14:00.
    Can any one have any example..?

    If on a Windows platform, you could run your Java class via a [Task Scheduler|http://support.microsoft.com/kb/308569].

  • Stop the running Thread

    Hi
    i am calling the thread .in the midlle of running thread i have to stop the thread .please help me .
    my senario like . I am calling the scripts . i am wating certain period to complete the script exection . if the scripts are not available its still wating for a long time . so i am using the thread to execute the scripts and (main thread )checking each duration is completed or not . if the duration completed i am stoping the thread with Thread.Stop() method . but the thread still is alive . next time when i call Thread.Start() its throwing "java.lang.IllegalThreadStateException".
    please help me this .
    Thanks in advance
    public class TestCaseScriptProcessor extends Thread {
    public String execute(){
    TestCaseScriptProcessor caseScriptProcessor = new TestCaseScriptProcessor();
    caseScriptProcessor .start();// second time throwing java.lang.IllegalThreadStateException.
    while (!isExpired) {
    caseScriptProcessor.stop();
    public void run() {
    Edited by: 849614 on Jan 17, 2013 6:17 AM
    Edited by: 849614 on Jan 17, 2013 6:22 AM

    What exactly are you trying to do? Calling Thread.stop( ) is inherently a bad idea (see the Javadocs).
    You are getting a IllegalStateException because Thread.stop( ) kills the thread, you would need to create a new thread to resume execution.
    If what you are trying to do is pause execution, you probably want to redesign your thread's tasks into smaller chunks that can be launched separately. Alternatively, have the thread check it's interrupted state and if a flag was set block on a monitor until you want it to resume execution.

Maybe you are looking for