How to stop a thread in java 5 for a real-time system??

Hi,
In Java 5, thread.stop is deprecated. We need to modify some variable to indicate that the target thread should stop running. "The target thread should check this variable regularly........"
We are currently developing a simple real-time operating system using the basic features of java. It is running on top of SunSPOT (JAVA5). My question is I need to stop a thread in a scheduler loop of a real-time operating system. We cannot check it regularly. Otherwise it is not a real-time operating system.Is there anyway else to do this?
Thanks,
Qing

That's rather hard to answer. You say you are writing in Java, but you're writing an OS. BUt what's executing the Java - you need a VM of some form. Is that a real-time or non-real-time VM? How it does things ultimately controls how effectively you can do what you are trying to do.
The simple answer is that Thread.stop() is deprecated and that it will not stop a thread in all situations anyway - eg trying to acquire a monitor lock. But all Thread.stop does is make an exception pending on the thread, and as the thread executes it polls to see if there is an exception pending. When this happens depends on the VM: it might be after every bytecode; it might be when the thread transitions states (eg thread-in-java, thread-in-vm, thread-in-native) - it all depends. But it is polling - just the same as checking that variable - it's just implicit in the VM rather than explicitly in your code.**
The RTSJ adds a new form of asynchronous termination requests through the AsynchronouslyInterruptedException (AIE). But it only affects code that explicitly declares that it expects AIE to occur, and there are also deferred sections where the AIE will remain pending. Writing code that can handle AIE is very difficult because the normal Java rules are "bent" and finally blocks do not get executed inside AIE-enabled code.
So as I said this is very hard to answer, it really depends what exactly you are running on and what you are trying to achieve.
** Note: some people used bytecode rewriting tools to add this kind of polling as a post-processing step. Perhaps that is something you might be able to do too.
David Holmes

Similar Messages

  • How to create a c++ shared library (.so) for linux real time (for myRio) with Eclipse to use in LabView?

    I tried already these Tutorials and Advices but I didn't find a solution:
    - http://www.ni.com/tutorial/14625/en/
    - http://www.ni.com/tutorial/14690/en/
    - http://forums.ni.com/t5/LabVIEW/Shared-Library-on-myrio-Linux-Real-time-system/m-p/2842540/
    - http://forums.ni.com/t5/LabVIEW/How-to-create-shared-library-for-linux-real-time-target-in/m-p/28218...
    - and some more
    I want use c++ codes on linux real time. For testing reasons I want to have a function that adds 2 values and gives the result.
    I've done these steps:
    1. writing a c++ file in Eclipse (see screensot 2)
    2. building a shared library (.so) from my c++ project in Eclipse (with Cross GCC)
    3. putting this file on myRio (path: /usr/local/lib/)
    4. creating a VI that calls this library from Labview with a "Call Library Function Node" (see screenshot3)
    5. Setting the properties for the "Call Library Function Node" (see screenshots 4-7)
    After I run this VI i get this error message: LabVIEW:  (Hex 0x627) The function name for the ... node cannot be found in the library. To correct this error, right-click the Call Library Function Node and select Configure from the shortcut menu. Then choose the correct function name. (see screenshot1)
    I've tried a lot things to solve this problem but I couldn't find a solution. Would be very happy if anyone can help me. I guess that I have to edit my c++ code to export my function (symbol). But I have no idea how to make it. I also tried it with a dll file in the same folder but it didn't help.
    Perhaps someone can send an example which works on myRIO.
    Thanks!
    screenshot1
    screenshot2
    screenshot3
    screenshot4
    screenshot5
    screenshot6
    screenshot7

     can see it in the screenshot8 there is a function called "_Z8AddierenddPd" instead of "Addieren". I copied this name to Labview (see screenshot9) and it worked.
    I'm sure that there is a way to compile the shared folder with gcc without decorations (mangling). But I don't know how. If someone has a recommendation I would be very glad!
    Prepend each function declaration that you want to be available without name decoration with
    extern "C" <your function declaration>
    Or if you have multiple functions you want to export you can in the header file where you declare your functions simply use:
    #ifdef __cplusplus
    extern "C" {
    #endif
    <all your function declarations>
    #ifdef __cplusplus
    #endif
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to stop a thread in java 1.5 on windows

    Hi All,
    I am using Java 1.5 on windows plateform. I want to stop all the threads which belongs to a particular process when the timeout occurs. In java 1.5 stop() method is depricated and interrupt method just sets the flag and does not stop the thread actually.
    Is there any way to destroy the thread permenently. I am using TheadPool Executor class.
    Regards
    Rinku Garg

    Hi,
    I am having a timer task which is scheduled to run after some fixed time interval when the process started.
    Now this timer task when started, should destroy the active threads of the request. When the request is timed out then the thread is action should termininate.
    In my case run method of particular thread had already made a call to Database through DAO when the time out occurs. So how can I set up a loop in run method which I found on google.
    thread.stop() is deprecated.
    thread.destroy() is deprecated.
    I used thread.interrupt() but it does not stops the thread.
    Please help me in this scenario.
    Regards
    Rinku Garg

  • HOW TO STOP you are opening this program for the first time

    I continue to get the warning "you are opening this program for the first time".  I don't want that warning to ever appear again for any program.  How to permanently get this warning to never again appear?
    Best regards,
    Steve Schulte
    Wednesday 21 November 2012

    Thomas,
    The reason I don't want these warnings (especially for programs that I have had on my Mac for years!) is because I now use ecamm's "Printopia" to send items from my iPad3 running iOS 6.0.1 to my MacBook Pro-13 (mid-2010) running Mountain Lion 10.8.2 -- and in order to do this:
    1.  Both my iPad and Mac have to be on the same WiFi network.
    2.  The Mac has to be awake, cannot be in the "sleep" mode
    OK but in order to wake my Mac, I've found that using the app "Remote" on my iPad to open iTunes AND PLAY A SONG will "waken" my Mac*.
    So now, for example, I send a .jpg file to my Mac.  I have it set so that GraphicConverter opens when a .jpg file is to be opened.  OK but if this warning appears (and even though I have had GraphicConverter on the Mac since the beginning of time…) I sometimes (like today) get this warning.  Of course I am not at my Mac and yet when I eventually go to my Mac-- there is that dialog box sitting there and until I click OK the photo doesn't open (and on my iPad I don't get a confirmation that it has been sent, because it hasn't until I click OK on the Mac).
    This could happen for other types of files, too - text files or Word documents etc.
    It seems to happen when I UPDATE a program, like when GC went from 8.3 to 8.3.1 for example.
    Thanks for any additional comments.
    *Perhaps there is a better / faster / easier way to "waken" my Mac from my iPad?  This is the only way I have found so far…

  • How can I control external MIDI devices from my PXI Real-time system?

    I am trying to implement a psychoacoustic experiment using an external MIDI device that can be used to shift the pitch of a speaker's voice.
    I have a 8176 controller in a 1002 chasis with the 6052E IO card. I would very much prefer to run the system in real-time mode (rather than win XP), and need to control the MIDI device through one of the interfaces on the controller.
    Any suggestions?
    Thanks in advance,
    Frenk

    Hi Frenk,
    one way would be an analogue to MIDI converter.
    There are some out there (ask for music equipment)which can convert an analogue signal to some MIDI controller signal. This way you could control the pitch shift with an analogue output of the 6052 in realtime.
    Hope this helps
    Regards
    Stephan

  • How to stop the thread?

    Hi,
    How to stop the thread in java. This is my program.
    import java.net.InetAddress;
    public class ThreadPing extends Thread {
         ThreadPing(String pingIP)
              super(pingIP);
              start();
         public void run()
              try
              String pingIP = Thread.currentThread().getName();
              InetAddress inet = InetAddress.getByName(pingIP);
              Boolean get=inet.isReachable(1500);          
              if(get==true)
                   System.out.println(inet.getHostName());               
              }catch(Exception e)
         public static void main(String args[])
              for(int i=1;i<=100;i++)
                   String pingIP = "192.168.1."+i;
                   ThreadPing tp = new ThreadPing(pingIP);
    Thanks in advance.

    The simplest way to stop all the thread is to make all thread daemons and exit the program when you want them to stop.

  • How to stop main thread ?

    Hi,
    Inside my java class, after I launch a GUI, I want to stop this main thread. After user make some choice and close GUI window, then, I want to go back to main thread. I use wait() method inside my class to stop main thread , but it does not work and it give me "IllegalMonitorStateException" error. I met same thing, when user close the GUI window and call method notifyAll(). How to stop main thread for a while and how to go back?? Thanks
    Gary

    Hi,
    you can create a boolean, and create a while loop, with a Thread.sleep(time); when you want to continue, you just have to change the state of your boolean. So you don't hava to exit the main. And you can't restart a run() in a thread. You can run it only once, so try to keep in your run() with an appropriate loop.
    Hope it helps.
    S�bastien

  • How to stop process chain, if it is taking too much time than expected.

    Some times if a process chain takes to much time to finish than expected, how I can stop the process chain and execute it again.
    Thanks in Advance.
    Harman

    how I can stop the process chain ??
    If the job is running for a long time ,
    1)GOTO RSMO and SM37 and check the long running job over there.
    2)There you can see the status of the job.
    3)If the job is still running you can kill that job
    4)delete the failed request from data target.
    for more details go to this below link
    how to stop process chain if it yellow for long time
    how I can execute it again ?
    GOto Function module  RSPC_API_CHAIN_START
    and give u r process chain name there.and execute.

  • How can I save/write data on the hard disc of the Real-Time System?

    I would like to acquire huge size of data via LabView Real-Time System.
    Since data is so huge, I am now thinking that it might be good idea to
    write/save data on the hard disc of the Real-Time System first and then
    transfer the data file to a data processing PC using FTP etc.
    If you know how to save/write data on the hard disc of the Real-Time System
    (Ver. 7.1), please let me know.
    Thanks,

    Just to add to Aitortxo's good answer,
    Since you have only one Drive ( C:\) on your RT, just keep monitering the availible disc space.
    After every few set of file writes keep transferring Backups delete these files, so that you  keep C:\ drive space for running your applications.
    Regards

  • I have iphone5 and now been given Nokia lumia 520 for work. How can I ensure that my calendars all sync in real time between each phone? Many thanks for any advice

    I have iphone5 and now been given Nokia lumia 520 for work. How can I ensure that my calendars all sync in real time between each phone? Many thanks for any advice

    Well if you got the Phone Pggray43 at a Local Corporate store in your Area)  you should be able to return it as long as you have all the contents.!  Phone, Charger and any other accessories that came with it the Box of Course.. As long as you have not went past the 14 Day return.. the store can go over what you used as in Air Time and Data..
    Now if you've went past the 14 Day return you be Liable to pay a E.T.F =  Early Termination Fee the fee for this is around $300 so hopefully you have not went past the 14 Day return window the Manager if Available is the one I would talk to tell them your on Social Security and you just can't afford a phone as this I'm sure they'll work with you to get something solved..
    Hope ya have Good Luck.! b33

  • Java Real-Time System HotSpot(TM) Client VM warning: unable to lock pages i

    Error:
    Java Real-Time System HotSpot(TM) Client VM warning: unable to lock pages into memory
    I'm getting this error, although I have assigned all the needed privilegs to root and I am logged in as root. I have done everything described in the guidelines to get the privilegs, but still this warning occurs.
    But my application still works completely with no appreciable differences.
    So my question is: Does this warning affect the performance of my application?? Or can I live with this warning?
    Gordon

    Determinism is an important issue in my application. That's why page locking should be active in my application. When I'm determining the ScopedMemory size via VM like:
    ... -XX:ScopedSize=500000000 ...Then page locking works with a size of 500 mb very well. But when I try to set the ScopedSize value to 1 gb, then the exception (unable to lock page...) is thrown. So it seems as if I had all the required rights, but the huge size is not supported.
    The System has about 6 gb of DDR2Ram and minimum 5 gb are free during starting the VM. So are there any other parameters except ScopedSize that I can change, to allow the VM to lock memory with a size of about 1 gb? Or where is the problem with locking such big sizes?
    Thanks,
    Gordon

  • Where to find Java Real-Time System Evaluation

    Hello,
    I tried to download an evaluation version of the Java Real-Time System from this page: http://www.oracle.com/technetwork/java/javase/tech/rts-142899.html
    But, when i try to download the "Java RTS 2.2 - Academic Developer Use" for Linux x86 32bit, i get the following message: "The Java Real-Time System evaluation program is closed at this time."
    Is the evaluation program expired? Where could i find an evaluation version of JRTS?
    Thank you all for your attention,
    Greetings.
    Andrea

    Determinism is an important issue in my application. That's why page locking should be active in my application. When I'm determining the ScopedMemory size via VM like:
    ... -XX:ScopedSize=500000000 ...Then page locking works with a size of 500 mb very well. But when I try to set the ScopedSize value to 1 gb, then the exception (unable to lock page...) is thrown. So it seems as if I had all the required rights, but the huge size is not supported.
    The System has about 6 gb of DDR2Ram and minimum 5 gb are free during starting the VM. So are there any other parameters except ScopedSize that I can change, to allow the VM to lock memory with a size of about 1 gb? Or where is the problem with locking such big sizes?
    Thanks,
    Gordon

  • How do I sign in to my iTunes for the first time? Everytime I try it says I have not used iTunes before, and to review my account information.

    How do I sign in to my iTunes for the first time? Everytime I try it says I have not used iTunes before, and to review my account information.

    It sounds like you are trying to create a new icloud account, not just logging into an existing account.  When you type in your Apple ID and get that error, it's because you are trying to create an account using the same ID that is already being used in another account.
    Go to Settings>iCloud and scroll to the bottom of the screen.  If you are logged in, press the Delete button, then try logging in with the existing ID.
    As for pics, the most secure way is to connect ipod to PC with USB and look at the Photos tab for your device in iTunes.  Using Photo Stream is another way, but it doesn't always work, depending on conditions.

  • Satellites L650D: how long do i leave it on charge for the first time?

    just recently bought this computer Toshiba Satellite series L650D and was wondering how long do i leave it on charge for the first time on power????
    Please help

    Hello
    If the battery is fully charged, the battery LED will switch the color. Depending on your notebook it will switch from orange to white for example. After this the battery is fully charged.
    The charging time is also depending on the battery, AC/DC adaptor and if the notebook is truned on or off. So nobody can exactly say how long it takes but the battery LED will it show you. :)

  • How long the iPod 5 should be charge for the first time

    How long the iPod 5 should be charge for the first time?

    It is best to just make sure it is fully charged. There is no problem charging it and using it at the same time too.

Maybe you are looking for

  • Is this an iTunes sync bug?

    I have an iPhone5 running iOS6.1 with iTunes 11.0.1.12 running on a Windows 7 PC.  Here's the scenario:  I have all my books sync'd up properly between my phone and iTunes.  If I use my phone to download a book I previously purchased (the book icon h

  • To diplay write  date format in an  input field

    I have written this code to get the curent date. Date  date=new  Date(System.currentTimeMillis()); *     //String dateString=date.toString();*     String dateString =date.getMonth()+"/";     String dateString1=date.getDay()+"/";     String dateString

  • Migration from MS SQL to Oracle/DB2

    Hi Gurus, Not sure if I post in the correct thread. But I need advice on migrating our MS SQL database to either Oracle or DB2. From ABAP point of view, I believe the standard SAP programs and most of our customized programs are compatiable with any

  • 11g Client result set caching in OCI

    I'm trying out this feature in the 11.1.0.6 release. My understanding of this feature is that when enabled with the appropriate server-side init.ora parameters, a 11g OCI client connecting to the instance will cache SQL results locally in some fixed

  • BOM (Bill of Material) Master Data  in Business Content?????

    Hi all, Any idea about standard business content data source which contains the BOM - bill of materials data..... Best Regards, Navin