Is there a way to run two different threads indefinitely

I have two different threads and they both are doing different tasks.... I want them to be running indefinitely....
i want the threads to run indefinetly passing the control between one another( anyway, passing the control is unpredicatable)
I dont want the tasks to be run in a infinite loop but the threads itself, which are doing their respective tasks.....

vinney_143 wrote:
anyway, with respect to what i understood, this is what i tried.............. i thought of calling the start() methods within a loop but it should be throwing illegalThreadStateException. so, i came to this forum to seek some help on this.
If i am gonna put the loop inside the threads, i dont think that serves my purposes of calling two threads indefinitely and not doing a task in each thread indefinitely........Threads have states: NEW, RUNNABLE, BLOCKED, WAITING, TERMINATED. When you create a thread (as an instance of thread) it is in NEW state. When you call start() on the thread instance it goes into RUNNABLE state. Process scheduler chooses a thread in runnable pool and runs it on the processor. When a thread goes to RUNNABLE etc states it can not go to NEW state (thats illegal). From a RUNNABLE state thread can only go to BLOCKED, WAITING or TERMINATED states. You can't call start() on the thread more than once. Once a thread is terminated (TERMINATED state) it can't go to NEW state either. Once start() is called the thread is started and you write logic that determines when the thread is terminated. Thats the reason why you got an IllegalThreadStateException.
while(true) {
    thread.start(); // throws IllegalThreadStateException
}Heres one way to keep thread running till a certain condition is met.
class MyThread extends Thread {
    public void run() {
        while(true) {
            boolean condition = //
            if(condition) {
                return; // terminates thread because run() returns
}Hope this helps.

Similar Messages

  • Is there a way to consolidate two different Apple ID's into one. I have an old Apple ID that I used for Itunes and a new I used to set up my iphone.

    Is there a way to consolidate two different Apple ID's into one. I have an old Apple ID that I used for Itunes and a new one I used to set up on my iphone.

    You cannot merge accounts.
    Why did you start a new account?

  • Is there a way to have two different iTunes for two different iPhones on one Windows User account?

    Using Windows 7, iphone 4.
    I've read as many threads on these forums and as many kb's as I could find, but I sttill can't figure it out. I have 2 iPhones. Let's call them, "wife" and "hubby". I want to have two separate iTunes, one for each of the phones. Hubby is the Windoows User. I don't want to set up a different Windows User for wife.
    Hubby was the original iPhone. When I plug it in, iTunes recognized it has Hubby's iPhone. Then I unplug Hubby and close iTunes. I plug in Wife but iTunes stll comes up with Hubby under Devices and syncs Hubby's iTunes to Wife's iphone.
    I've tried using the shift key when I open iTunes to set up two separate .itl files to no avail.
    Is there a way to have two different iTunes for two different iPhones on one Windows User account?
    Thanks!

    What happens if you rename the iPhone "Wife" when it shows up as "Hubby", then choose a different set of apps/playlists to sync with? iTunes is supposed to be able to manage multiple devices, each with their own selection of content. Perhaps you "restored" "Wife" with a backup from "Hubby" when you first set things up which is now causing confusion.
    To create a new library press and hold down the shift key as you click the icon to start iTunes and keep holding shift until asked to choose or create a library. You need to use the same technique to switch back.
    tt2

  • Is there a way to make two different text fields be "either or" like a "yes no" check box?

    I'm have Acrobat 9 Pro on a Mac running Yosemite.
    I have two text fields that each are formatted to have a number entered, but the user chooses which to fill out — either "number of weeks" OR "number of months" (two separate text fields). I don't want them to fill out both fields, only one of them.
    Is there a way to set up these two text fields so that only one can be filled out? (Sort of like when you have a "yes" and "no" check the box field, you name them the same but have different export values?)
    Thanks for any help provided.
    ~ bexterinni

    Only by custom JavaScripting.

  • Project Web App (PWA)/Sharepoint 2013: is there any way to display two different views of the Project Center PWA web part to the same user in a site collection?

    i want some of my users to see all the projects in the Project Center at my top-level site, and those same users to see only the projects they own at a subsite level in Project Center. that way they could see an 'all project' view on the homepage and only
    their projects on their dashboard pages (which also have an instance of Project Center web part on them). i have searched and searched but cannot find a solution to this. is there any way to acheive this functionality? thanks in advance for your assistance!

    I have tried this in the past, but was not successful, as far as I can recall. Once you access the project center webpart in one page, the view will be retained regardless where you see it again. (until you apply a different view or clear your browser cache). 
    May be an easier solution is to display a 'report' on the home page with ALL projects (much easier to do), and use the Project Center webpart for the My projects view as it is easier to achieve via Project Server Security, than a report.
    Cheers,
    Prasanna Adavi, Project MVP
    Blog:
      Podcast:
       Twitter:   
    LinkedIn:
      

  • Is there any way to scroll two different documents simultaneously?

    Hi all, scroll two different documents simultaneously  - it will be helpul while doing corrections / checking documents. Is there any plugin available for this?

    I use two computers (don't laugh). I set up the laptop next to my desktop monitor and use one hand on each keyboard.
    Consider using (if appropriate) compare tools as well. You can export both documents to RTF and use Word to compare them if all you care about is textual differences. You can export both documents to PDF and use Acrobat to compare them if you need to see graphic differences as well.
    Ken

  • Is there a way to set two different settings for the backlight?

    I was wondering if there is a way for me to set the backlight to always on when watching videos on my 5G 30 gig iPod and off when doing anything else?
    Or do I have to manually go in and change the setting everytime?

    The backlight will always be on when watching videos. This is automatic, regardless of the setting.
    btabz

  • Is there a way to give two different regular expressions in a Grep command?

    I am trying to search message logs from CLI. My search query which involves a regular expression is giving thousands of results. We need to further filter the results using another regular expression. Please let me know if we can put two regular expressions in the search query.
    Below is how I use grep command: Can I use multiple regular expression separated by a "|" (pipe) symbol
    Enter the regular expression to grep.
    []> MID 123456

    No - unfortunately - from the CLI on the ESA/SMA - the 'grep' command is not as intuitive as the unix/linux 'grep'.  You would need to push logs off appliance, and then take advantage of an external OS in order to parse through the logs as definitively needed.
    -Robert
    (*If you have received the answer to your original question, and found this helpful/correct - please mark the question as answered, and be sure to leave a rating to reflect!)

  • How can I run two different versions of Firefox, the latest does not work with an important site I need to use?

    With the latest version of Firefox I cannot send "Quick Mails" to my students using the college's ANGEL system. I had to uninstall it and go to an earlier version. I prefer the newest rev.
    Any way to run two different versions. It does not have to be simultaniously. Seems to be a problem on both my Mac and XP systems.
    Thanks,
    Kim

    Currently I don't think there is a way to run two version of firefox at the same time. But you can install Firefox Beta or Aurora instead (which is build for future release for firefox) and help test it! Here's the link:
    http://www.mozilla.org/en-US/firefox/channel/

  • If I have multiple accounts in my mail on a macbook, is there a way to separate the different accounts like in two separate tabs?

    If I have multiple accounts in my mail on a macbook, is there a way to separate the different accounts like in two separate tabs?

    I can't think of a way to show them in tabs, but Mail lets you open as many Mail list windows as you like. Set the Mail window to show just the inbox for Account A, then choose File/New Viewer Window and set that window to show just the Account B inbox. Arrange the windows next to each other.
    I open multiple viewer windows all the time when dragging messages from inboxes to various folders, it saves a lot of time.

  • Is there a way to have two separate projects open in different windows?

    On my old editing software, I could have two separate projects open at the same time. I could copy clips from Project A, click over to Project B, and paste the Project A clips to Project B. Is there a way to have two separate projects open with Premiere Elements, or will I have to just import and trim every clip within the same project?

    Welcome to the forum.
    Unfortunately, PrE will not allow two Projects to be open at the same time. It will also not allow multiple instances of PrE to be open.
    The workaround, to accomplish what you describe, is to use a ClipBoard Extender, such as ClipMate, which will allow one to Copy a Timeline, or parts of it, from one Project, then Close that one, to Open another one, and Paste the material, that was Copied. Many users employee ClipMate, or similar, to Copy/Paste material from one Project, to another.
    Good luck,
    Hunt

  • Is there a way to run Motion and Final Cut Pro on Separate Machines?

    Is there a way to run Motion and Final Cut Pro from the same Final Cut Studio license on separate machines? We hadn't realised when we bought Final Cut Studio that it wouldn't allow this. Our editor doesn't use motion, and while I mainly use After Effects on our motion graphics machine, I was wanting to try using motion for some particle effects. Unfortunately, it won't let me open it while Final Cut is running on our editor's machine. I can understand not letting two copies of same application run under the same serial number at the same time, but it would be nice to be able to use both programs that we own concurrently. At very least it would be good to warn you that this isn't possible in the product description, not in some fine print license agreement once you have already bought the software.
    -Matt

    I do not know of any software, in any platform that can operate from the same license over a network simultaneously.This is the exact reason for the existence of Volume Licensing. If for example a project ran in each one of the included applications from different sources that were not an active network, I doubt you would have a problem.Like, doing a project at work and geting the outcome with the Powerbook at home...Sorta!

  • Running two different tests on separate monitors

    Can I run two different labview executables from one PC on separate monitors
    simultaneously? I have a 2 station test facility which I would like to use 1 PC and 2 touchscreen monitors so the 2 operators ccan run different tests on each station  simultaneously.
    Solved!
    Go to Solution.

    As long as you are careful about not using the same resources (files, DAQ devices, etc), you can have as many executables running as you want.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Is there a way to add two windows in the same window?

    is there a way to add two windows in the same window?

    what do you mean by your first use of the word "window"? do you mean a visible frame? a section of the gui that the user doesnt see?
    or perhaps you mean you want to add multiple tabs to a single window, so that switching between tabs shows different windows?

  • Is there a way to run a 2005 PreSonus Firebox(with the firewire) to a mid-2011 iMac 0SX 10.7.2? It says its no longer supporting Power PC? Anything I can do without spending more money on new equipment or a new computer? Please help me.

    Is there a way to run a 2005 PreSonus Firebox(with the firewire) to a mid-2011 iMac 0SX 10.7.2? It says its no longer supporting Power PC? Anything I can do without spending more money on new equipment or a new computer? Please help me.

    Nevermind, I got it working.
    I ended up extracting the new vob within MPEG Streamclip, which gave me an m2v and an aiff audio. I multiplexed those two back together in FFMpegX which gave me a complete VIDEO_TS folder with BUP and IFO files I needed.

Maybe you are looking for