Threads waiting the same event :searching for a specific notificationfor

hi all,
i have two thread waiting an event
and another who notify them
//the class event
public final class Event {
* variable used to store the notification if it takes place
* before being expected
private boolean status = false;
public final synchronized void waitForNotification() {
while (status == false ) {
try {
wait();
catch (InterruptedException e) {
status = false ;
// notify all waits on this event
public final synchronized void wakeUp() {
status = true;
notifyAll();
// the class TestThread implements a thread that have an event waiting for a notification
public class TestThread extends Thread{
private Event event;
public TestThread( Event e){
event=e;
public void run(){
for (int i = 1; i < 4; i += 1) {
try {
Thread.sleep(2);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
e.waitForNotification();
// the class TestThread2 implements a thread that have an event waiting for a notification
public class TestThread2 extends Thread{
private Event event;
public TestThread( Event e){
event=e;
public void run(){
for (int i = 1; i < 4; i += 1) {
e.wakeUp();
//the class main
public class test {
* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
Event e = new event();
TestThread th1 = new TestThreadConsumer(e);
TestThread th2 = new TestThread(e);
TestThread2 th= new TestThread2(e);
th1.start();
th2.start();
th3.start();
1st case
the problem is that the notification could not be seen to the tow threads
because if the tow are waiting the notification
and the other thread send notification
one of the tow see the notificztion and wake up and set the flag status to false so the other one could not ever wake up
2d case
the notification of the second thread could be done in the second itiration or in the other ones
please could u answer and help me
thank you

I'm locking this thread since it's a duplicate.
The discussion will continue in: [http://forums.sun.com/thread.jspa?threadID=5377151&tstart=0]
Kaj

Similar Messages

  • Threads waiting the same event

    hi all,
    i have two thread waiting an event
    and another who notify them
    //the class event
    public final class Event {
    * variable used to store the notification if it takes place
    * before being expected
    private boolean status = false;
    public final synchronized void waitForNotification() {
    while (status == false ) {
    try {
    wait();
    catch (InterruptedException e) {
    status = false ;
    // notify all waits on this event
    public final synchronized void wakeUp() {
    status = true;
    notifyAll();
    // the class TestThread implements a thread that have an event waiting for a notification
    public class TestThread extends Thread{
    private Event event;
    public TestThread( Event e){
    event=e;
    public void run(){
    for (int i = 1; i < 4; i += 1) {
    try {
    Thread.sleep(2);
    } catch (InterruptedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    e.waitForNotification();
    // the class TestThread2 implements a thread that have an event waiting for a notification
    public class TestThread2 extends Thread{
    private Event event;
    public TestThread( Event e){
    event=e;
    public void run(){
    for (int i = 1; i < 4; i += 1) {
    e.wakeUp();
    //the class main
    public class test {
    * @param args
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Event e = new event();
    TestThread th1 = new TestThreadConsumer(e);
    TestThread th2 = new TestThread(e);
    TestThread2 th= new TestThread2(e);
    th1.start();
    th2.start();
    th3.start();
    1st case
    the problem is that the notification could not be seen to the tow threads
    because if the tow are waiting the notification
    and the other thread send notification
    one of the tow see the notificztion and wake up and set the flag status to false so the other one could not ever wake up
    2d case
    the notification of the second thread could be done in the second itiration or in the other ones
    please could u answer and help me
    thank you

    nabila.abdessaied wrote:
    i just wanna to have tow thread waiting a notification from another
    and when another send the notification
    they could go out from waiting and do their jobHi.
    Below is an example of how you could do this. It is taken from http://www.javaconcurrencyinpractice.com/listings.html (5.11 Using CountDownLatch for starting and stopping threads in timing tests) .
    The idea is simple:
    (1) main thread starts nThreads, but all of them, once started, are "suspended" in startGate.await();
    (2) when all threads are started, main thread calls startGate.countDown(); and all those waiting threads "are off" at once.
    I'm not sure that you need 'endGate' though (but I thought that it is not that good to cut somebody's else example...)
    * TestHarness
    * <p/>
    * Using CountDownLatch for starting and stopping threads in timing tests
    * @author Brian Goetz and Tim Peierls
    public class TestHarness {
        public long timeTasks(int nThreads, final Runnable task)
                throws InterruptedException {
            final CountDownLatch startGate = new CountDownLatch(1);
            final CountDownLatch endGate = new CountDownLatch(nThreads);
            for (int i = 0; i < nThreads; i++) {
                Thread t = new Thread() {
                    public void run() {
                        try {
                            startGate.await();
                            try {
                                task.run();
                            } finally {
                                endGate.countDown();
                        } catch (InterruptedException ignored) {
                t.start();
            long start = System.nanoTime();
            startGate.countDown();
            endGate.await();
            long end = System.nanoTime();
            return end - start;
    }Seems this is what you were looking for (if I understood you right).

  • How can I use the same event case for different controls dynamically

    OS: Linux 2.6.24-1-686 #1 SMP Sat Apr 19 00:37:55 UTC 2008 i686 GNU/Linux
    LabVIEW: Version 8.2
    I have a lot of (about 50) controls (numeric, boolean) on my front panel. If a "Value Change" event will be fired by any of them the same event case shall be executed. As I do not want to add all 50 controls to the same event case manually I am looking for a way to do it at run time. Additionally the VI is still under contruction, i.e. controls will be added and removed.
    Thanks for any help here.
    Regards,
    Johannes
    Solved!
    Go to Solution.

    Hi Johannes,
    collect all your control references (you can use the FP property for it) and create a user event. Connect this user event to your event structure. Now you have one event case for all your controls. See the attached picture.
    Mike
    Attachments:
    Unbenannt1.PNG ‏11 KB

  • ICal has dropped a monthly event for the previous four months....... why did it disappear? and where is it?  It was the same event but a different day each month.

    iCal has dropped a monthly event for the previous four months....... why did it disappear? and where is it?  It was the same event but a different day each month.

      I installed this same digitizer in my T|X some weeks ago.  Some discussion of my experience may be found in this Usenet posting and subsequent thread.
      The stock digitizer in my T|X had always had some significant alignment issues (for which PowerDigi was able to compensate very nicely) and sensitivity which was uneven, but which usually required a heavier touch than I liked.
      Eventually, it began to develop a “dead spot” near the upper left.  My T|X was under warranty, so I probably ought to have sent it in to Palm to be repaired, but I wasn't willing to be without it for the required amount of time, and I've heard enough reports of other T|X owners getting unsatisfactory results this way.  I'd heard enough good reports about the PDAPARTS.COm digitizer, that I decided that the only acceptable way to repair my T|X would be to install one of those.
      After however many weeks it has been, I am still very pleased with the results.  It continues to work flawlessly; it is much more sensitive, so it doesn't require nearly so heavy a touch, and I very much like the hard feel that it has, compared to the spongier feel of the stock digitizer.
      My wife's T|X still has its stock digitizer, and it has so far not shown any of the same problems that mine did, or for which the T|X has become notorious, but the feel is noticeably inferior.  She's content with it the way it is, but I think that if I were to ever buy another T|X for myself, I wouldn't wait for the stock digitizer to fail.  The PDAPARTS.COM digitizer is simply superior in every imaginable way; and, in my opinion, a T|X with the PDAPARTS.COM digitizer installed is sufficiently superior to one with the stock digitizer (even if it isn't defective) to be very much worth the expense and trouble of installing it.
    Post relates to: Palm TX

  • How to get rid of mutiple events showing in calenders for the same event

    How do you get rid of mutiple events that show up in your calender of the same event. It doesn't matter what kind of event it is whether personel or yearly holiday it shows up mutiple times in the month view, list view. I've gone through and deleted events manually and said for all future events but this is time consuming, because you have to do it for each event. Is there a qicker way of getting this done? Also just an off note I found out that my bluetooth headsets stop ringing throught the ear piece like they did before the upgrade, any insight into this?

    If I understand your question correctly...
    try the following
    from Sources, choose the greyed out streaming library that you want to be rid of...in your case, make sure it is the right one, since they both have the same name.
    You should get a screen that says "Library Unavailable" with 2 menu choices below that, "OK" and "Disconnect from iTunes".
    Choose disconnect from iTunes and the library should be gone from your Sources.

  • Duplicate reminder emails for the same event

    Some of my users are experiencing duplicate reminder emails for the same event. These duplicates have the same bodies, different message-id headers and posted at exactly the same time.
    Has anybody seen this sort of behavior and know a fix.

    We had the same problem. At us I noticed the start/stop from the server went wrong. There were double processes running from the server. You should have 1 admin process, 1 notify process, 1 enpd process and (same as your cpu count) httpd processes.
    When the other ones are more then 1, restart the system.
    This receiving double e-mail reminder problem, you will only find at people who have AND event notifications on AND event & task reminders on! People who don't have BOTH activated, don't receive double reminders.
    Also watchout that your test calendar system can't send e-mail notifications to your production users. But this you can see by reading the headers from the e-mail .. the system where it comes from is then different.
    Hope this helps.
    Greetz,
    Miranda

  • Workflow sending 20 email notifications every one hour for the same event

    Hi Experts,
    We had an issue on a clientu2019s prod system that the workflow triggered the same event 20 times in one hour. Later, a client has resolved the issue by removing the information from the workflow administration and reentering it back again. The workflow administration contains email settings, web settings, workflow roles, and active workflow maintenance. Although, the issue has been resolved but a client still needs to know how that happened. I would like to get some helpful opinions on how this happened because I am very new to the workflow. I would really appreciate your opinions.
    Thank you
    Don P.

    Hi Sue,
    Thank you for your response. I am not sure if the event has been triggered erroneously. The client told us that it didn't happen in the dev system when he tested it, but it only happen in the prod system. This project went live a little bit over a year ago without any issues, but it just happened the first on 6/22.
    The event is about to notify the user to review a new incident report (EHS), and it's same event id for all 20 email notifications. We will a client to look into their system about how this event raised?, what does the event log reveal? and if he uses the event queue. Again, thanks for your response.
    -Don P.

  • Can I have multiple event structures with the same event cases?

    Hello, 
    I'm doing an application that reproduces the front panel of the HP6675A power supply. To achieve this, I have done a state machine with different states
    (initialize, measures, voltage, current, ocp, ov, store, recall, etc). In each state, should have an event structure that catches the events of the buttons, like for example: if the current state is the Voltage mode and the user press the current button the next state will be the Current mode. For this in each state of the state machine should be the same event structure with the same events.
    My problem is that the Vi doesn't work properly when I have multiple event structures with the same event cases. There are some possibily to do this, and how? Or is impossible to have multiple events? I have been reading some posts, but I don't find solutions. 
    Any help is appreciated.
    Thank you very much.
    Solved!
    Go to Solution.

    natasftw wrote:
    Or as others mentioned, make two parallel loops.  In one loop, have your state machine.  In the other, have just the Event Handler.  Pass the events from the handler to the state machine by way of queues.
    A proper state machine will not need the second loop.  The "Wait For Event" or "Idle" state (whatever you want to call it) is all you really need in order to catch the user button presses.  The setup is almost there.  Maybe add a shift register to keep track of which state to go to in the case of a timeout on the Event Structure.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Communication between thread in the same process using file interface.

    Hi,
    I am developing  driver and i need to communicate between two thread.
    >can anyone guide me on implementing communication between two thread in the same process using File Interface. First thread will be driver and second will be application.I need to send IOCTL like commands using File interface ie is WriteFile(),ReadFile()
    from Host process to driver through file-interface(which run's in driver context).Host process should not be blocked for the duration of the driver to process the command.
    >File-interface will run in driver context and it will be responsible to receive command from application and pass it to the driver.
    what are the complexity introduced?
    >Can anyone also give me the link/reference to get more information on this topic?
    >How to replace IOCTL command's for instance baud _rate change command with a file interface for example with IRP.

    Here  is the detailed query:
    Hardware Abstraction Layer will interact with Driver(Both will be running in complete different process) .there is a IOCTL for command and  File interface for read and write.
    My requirement is:
    Both should run in the same process so HAL will run as one thread and driver as another thread in the same process .I don't want HAL to wait for completion of request and also i don't want driver to be blocked .
    We are planning to use a File Interface for communication between Hardware abstraction layer and Driver
    HAL will send the command or read/write operation to a file interface and driver will get the command or read/write request from the File interface
    There is a flexibility to change Hardware Abstraction layer and also the Driver
    Is it possible to use IOCTL between two thread under same process? if not what other options do we have.
    Can we use File interface to  send command (like IOCTL) between two thread?

  • Can multiple threads share the same cursor in berkeley db java edition?

    We use berkeley db to store our path computation results. We now have two threads which need to retrieve records from database. Specifically, the first thread accesses the database from the very beginning and read a certain number of records. Then, the second thread needs to access the database and read the rest records starting from the position where the cursor stops in the first thread. But, now, I cannot let these two threads share the same cursor. So, I have to open the database separately in two threads and use individual cursor for each thread. This means I have to in the second thread let the cursor skip the first certain number of records and then read the rest records. However, in this way, it is a waste of time letting the second thread skip a certain of records. It will be ideal for us that the second thread can start reading the record just from the place where the first thread stops. Actually, I have tried using transactional cursor and wanted to let the two threads share the same transactional cursor. But it seems that this didn't work.
    Can anyone give any suggestion? Thank you so much!
    sgao

    If your question is really about using the BDB Java Edition product please post to the JE forum:
    Berkeley DB Java Edition
    If your question is about using the Java API of the BDB (C-based) product, then this is the correct forum.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • FCPX 10.1.3 Project vanishes when a new project is created in the same event

    I've been working on avery complicated project all day with multiple layered clips with key frame animations, colour effects etc. All was fine until I opened a new project in the same event which I was going to use to create some effects sequences for the main project. When I went back to the original project it was empty. Tried the Undo function in case I had done anything stupid but it was greyed out. Went to the FCPX backups and the last file was almost 2 hours old but did not have any sign of this project. The only thing I have left is all the imported media.
    Any ideas? Using FCPX 10.1.3. This is really annoying as all I have left is an h264 file of the almost complete project and it will be almost impossible to start from scratch.
    Thanks for your attention

    The edited project was 60 seconds making up an intricate title sequence involving 24 video segments and 48 png/ PSD files.  Had a brain storm and was wondering if there is anyway the the project could move to another event so currently going through all the event folders on my FCPX edit drive. I just can't see how a project can just vanish.
    Thanks for your suggestion.

  • I have photos from several cameras of the same event, how do I combine them?

    I have photos from several cameras of the same events.  How can I sort them together, three pics of the same horse from three cameras side by side; I can't move pics from one camera source to another in a folder.

    Languare is critical since it is all we have to communicate with
    Folders in iPhoto do not hold photos - folders hold only other folders or albums
    If you are speaking of events then you simply merge the events (drag one onto another or select two or more and use the merge events command - for the photos to be "side by side" the three camera's time/date setting will have to be identical as photos will be sorted by time/date - if they are not you can correct by selecting the photos in an event (before merging) and using the adjust time and date command or you can make a smart album for the camera and select the photos and use the adjust time and date command
    LN

  • How do I have the same "events" on two Macs?

    I have the "family pack" and just installed on both Macs. I have the same exact pictures on both Macs. I organized all the events on one Mac and now I would like to have the same events on the second Mac.
    On the previous version of iPhoto, I simply would copy com.apple.iPhoto.plist from the first Mac and copy it to the next Mac. Then all my preferences (e.g., file names, roll names, etc.) would match. This method does not seem to work on iPhoto 08.
    Any suggestions?

    John:
    You could use iPhoto Library Manager and copy the events from one library to another like this. The demo shows an event being copies but it works the same for albums.
    You'll need to connect the Macs so you have access to the libraries and then IPLM will do the job.
    Do you Twango?
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've written an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • Can you use the same charging cable for both an iPhone and an IPad or are they different?  When I use the charging cable for my iPhone on my Ipad, it doesn't charge.

    Can you use the same charging cable for both an iPhone and an IPad or are they different?  When I use the charging cable for my iPhone on my Ipad, it doesn't charge.

    The quickest way (and really the only way) to charge your iPad is with the included 10W USB Power Adapter. iPad will also charge, although more slowly, when attached to a computer with a high-power USB port (many recent Mac computers) or with an iPhone Power Adapter (5W). When attached to a computer via a standard USB port (most PCs or older Mac computers) iPad will charge very slowly (but iPad indicates not charging). Make sure your computer is on while charging iPad via USB. If iPad is connected to a computer that’s turned off or is in sleep or standby mode, the iPad battery will continue to drain.
    Apple recommends that once a month you let the iPad fully discharge & then recharge to 100%.
    How to Calibrate Your Mac, iPhone, or iPad Battery
    http://www.macblend.com/how-to-calibrate-your-mac-iphone-or-ipad-battery/
    At this link http://www.tomshardware.com/reviews/galaxy-tab-android-tablet,3014-11.html , tests show that the iPad 2 battery (25 watt-hours) will charge to 90% in 3 hours 1 minute. It will charge to 100% in 4 hours 2 minutes. The new iPad has a larger capacity battery (42 watt-hours), so using the 10W charger will obviously take longer. If you are using your iPad while charging, it will take even longer. It's best to turn your new iPad OFF and charge over night. Also look at The iPad's charging challenge explained http://www.macworld.com/article/1150356/ipadcharging.html
    Also, if you have a 3rd generation iPad, look at
    Apple: iPad Battery Nothing to Get Charged Up About
    http://allthingsd.com/20120327/apple-ipad-battery-nothing-to-get-charged-up-abou t/
    Apple Explains New iPad's Continued Charging Beyond 100% Battery Level
    http://www.macrumors.com/2012/03/27/apple-explains-new-ipads-continued-charging- beyond-100-battery-level/
    New iPad Takes Much Longer to Charge Than iPad 2
    http://www.iphonehacks.com/2012/03/new-ipad-takes-much-longer-to-charge-than-ipa d-2.html
    Apple Batteries - iPad http://www.apple.com/batteries/ipad.html
    Extend iPad Battery Life (Look at pjl123 comment)
    https://discussions.apple.com/thread/3921324?tstart=30
    New iPad Slow to Recharge, Barely Charges During Use
    http://www.pcworld.com/article/252326/new_ipad_slow_to_recharge_barely_charges_d uring_use.html
    Tips About Charging for New iPad 3
    http://goodscool-electronics.blogspot.com/2012/04/tips-about-charging-for-new-ip ad-3.html
    Prolong battery lifespan for iPad / iPad 2 / iPad 3: charging tips
    http://thehowto.wikidot.com/prolong-battery-lifespan-for-ipad
     Cheers, Tom

  • Use the same code module for several steps in the sequence

    Hello All,
      I have been trying to set up a sequence that uses the same code module for all of the steps in the sequence, but am having trouble referring back to it when I need to send it commands.  I have gotten as far as calling the VI in a new thread so that it can be run asynchronously.  I can run the simple sequence and it will indeed open the VI, and move on to the next step.  When I close the VI manually from the front panel, the sequence in TestStand completes, as expected.  So it appears that I have that much working. 
      My question is how to call the separate thread from the main sequence or other sub sequences when I need to edit the parameters.  If I insert an Action step, I am required to select a VI file, but from what I can tell, it opens a different instance of the file, and does not provide an interface with the other instance running asycronously.  My next guess was to use a Statement step, but I was not able to figure out how to configure the lookup string to call the VI parameters.  Beyond that, I'm not sure how to proceed.  Please advise.   
      My intention is to start the code module VI (asynchronously), run several different subsequences within the main sequence that call that same VI and edit it's parameters, close everything and report on the results.  If I am misunderstanding how TestStand is supposed to work, please let me know. 
    Thanks,
    GSinMN    
    Solved!
    Go to Solution.

    What I do is use a Queue to send data to the asynchronous VI.  So it can run and do whatever, but also recieve the commands from the queue.  I use an Action Engine that holds the queue reference and sends the commands.  So you really just have to call the Action Engine from your sequences.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

Maybe you are looking for

  • HT201303 How do I delete a credit card from payment options?

    How do I delete a credit card from payment options in the itunes store?

  • How can I update my mac os x 10.6.8 to get icloud?

    HOW CAN I UPDATE MY MAC OS X 10.6.8 TO GET ICLOUD?

  • How to create adf columns at runtime

    Hello I want to crete a component which will display results of arbitrary sql command. for that purpose I created 'declared component' with custom component class which obtains SQL query from passed attibute and executes it. so in my component I have

  • How to uninstall Careme

    Hi, I am Nokia E5 customer. How to uninstall this software? this is really worst i have ever experienced! after installing this i cannot see my call logs at all and when i want to access at lease careme logs i cannot find this anywhere in my mobile.

  • Workflow notification mailer not working properly

    Hi, I got the following error and I have restart the services but still facing the same problem, Please advice Definition ID 10006 Name Workflow Notification Mailer Startup Mode Automatic Container Type Oracle Applications GSM Inbound Agent Workflow