Thread notification with a response

Hi
I have a thread waiting on a string. The notifying thread do not have any idea who the waiting guy is and they do not share any common object either other than the string. I want to send back some information to the waiting thread when notifying it. And there are multiple thread-couples like this. How can I do it. I could use a hashmap to store the String object and the waiting thread. The notifier first looks up the waiting thread and sets the response and then notifies it. But this doesn't look very elegant. Anything in concurrent api's to take care of this? Or maybe I have missed on a very simple solution?
Biblio

Well, they share the string. In fact the notifier has another instance of the string and then I am calling intern on that to get the same instance as is with the waiting thread. String is the only object I can share in this case without maintaining a map on my side (vm does that for me). And I do not want to use any map. Can I use something like an exchanger? But again both the threads can't share the same exchanger either.
The code looks like
in Thread A -->
"someString".wait()
in Thread B -->
get "someString" contents from somewhere
some other data to be sent to the waiting thread
"someString".intern().notify()

Similar Messages

  • How to use notification with parallel thread

    Hi,
    I am learning to use Notification to communicate between thread. I still don't know how to use it. In my current project I have a case to use this so I think I should implement this technique. My example is I have a main sequence in that I make a new thread. What I want is the new thread will do a task A when receive a notfication or to exit the thread when the main sequence stop.
    I am not sure if using notification is a best practice here? Or should I use a reference data?
    What about if I want my thread to do task B if it receive another notification. Is notification still be helpful?
    Regards,
    Thang Nguyen
    Solved!
    Go to Solution.

    Hello,
    You can use Notification to handle parallel threads. I often create two sequences : one containing the process A of your example (StartProcessA). and a second one to stop this process (StopProcessA). In StartProcessA, I create a Notification, with a defined name (as string constante, "StopProcessANotifier" for instance) in the setup group. Then I have the process, in a loop. At the end of this loop, I check the Notification (Wait) with a  timeout enabled, and no error if a timeout occurs. this way, the Notification Wait can be used as loop timing, and if the notification is Set in MainSequence, this exit the loop (pick a look at Notification property Step.Result.TimeoutOccured).
    To sum up, use a first sequence call in MainSequence, calling StartProcessA, with NewThread option, and do not forget to call StopProcessA at the end of you MainSequence. The Cleanup group is a very good location, because it will be executed even in case of error.
    This is a very simple use of Notification. Note, I believe that make it simple is often the most important but also the most complicated thing to do 
    Hope this helps....
    .mrLeft{float:left} .mrInfo{border-left:solid 1px #989898;font-size:x-small;color:#989898}
    Mathieu R.  
      CTD - Certified TestStand Developer / Développeur TestStand Certifié  
      CLAD - Certified LabVIEW Associate Developer  

  • How to implement notification with response against each order lines

    We have a requirement wherein the multiple order lines should be displayed in one notificaiton and the response (Approve/Reject) should be line wise.
    For exmple, if an order has 3 lines, the approver should get one notification with all 3 lines displayed in the notification. Approver should be able to approve say 2 lines
    and reject the third line.
    If reponse is not possible line wise, is it possible for including a drop down/checkbox/text against each line which would enable the approver to approve/reject the line and the approver response against each line should be captured.
    How do we implement this?

    Hello,
    we are evaluating BC4J/JClient. In our application we have a navigation tree
    in a Java client from which we can call nested dialogs to set attributes,
    call business logic etc.
    Is it possible to open more than one sub-dialog from our starting navigation tree
    at the same time? Each sub-dialog should have its own transaction context.
    To our knowledge we need a new application module for each sub-dialog in order
    to start a new transaction. But how is the navigation tree updated if data
    from the sub-dialogs is commited? The dialogs and the navigation tree don't share
    the same model, do they? The navigation tree might have to show lots of data
    retrieved over a slow connection, so simply updating the entire model is not a solution.
    This could work if an intelligent caching fetches only the changed data.
    So: What is the best way to implement sub-dialogs with their own transaction plus an
    update mechanism?To create a UI like this, see the sample on OTN at
    http://otn.oracle.com/sample_code/products/jdev/jclient/jclient_binding_demo.html
    YOu'd have to tweak this sample so that each sub-window comes up with it's own AM (as you've right suggested).
    Regarding commit, yes, if you do not want to query the whole model on the navigator, you may use Transaction.commitAndSync() method to commit changes instead of simply performing a commit() call.
    See javadoc on this method for details on how it works.
    Thanks for any help!

  • What is the cost to have email notification feature?  I would like email notification when someone response to my form with attachments;so I can download them asap.

    What is the cost to have email notification feature?  I would like email notification when someone response to my form with attachments;so I can download them asap.

    Email notifications and email receipts are available with any of our payed plans.
    Andrew

  • Approval notification with email

    i would like to set up approval notification with email. when searching in help.sap.com i did not find the information i need. does anyone know where to find the information to configure that in approval process notifications are sent per email?

    Hi Matthias,
    see /thread/27876 [original link is broken]
    Hope it helps
    Detlev

  • Notifications to a responsibility or role?

    Hello,
    We are in a multi-org environment. I have set the HZ User Creation Workflow Administrator role item attribute as SYSADMIN. I would like to send notifications to a responsibility which in turn will send an email to the users of the responsibility. What is the best way to approach this?
    1. Create a new application responsibility/role (via the application) that is not multi-org assigned and assign the users to it.
    2. Create a new role via wf_directory api and assigns the applications users to it? This approach doesn't allow us to control the additions/deletions of user via the apps.
    Thanks in advance for any assistance.
    BA

    Hi,
    I would go with the first choice, and use an Apps Responsibility. That way, you can use the screens to manage the user list, rather than APIs.
    HTH,
    Matt
    WorkflowFAQ.com - the ONLY independent resource for Oracle Workflow development
    Alpha review chapters from my book "Developing With Oracle Workflow" are available via my website http://www.workflowfaq.com
    Have you read the blog at http://www.workflowfaq.com/blog ?
    WorkflowFAQ support forum: http://forum.workflowfaq.com

  • Email notification with SP 10

    Hi all,
    We are using Solution Manager 7.1 SP 10 and would like to use the "new" email notification with the new standard actions. Nevertheless, it seems that is doesn't work.
    Based on what we read, we should not need to create anything anymore as described here Pep Up Your ChaRM - Part 1: HowTo Create a Smart e-Mail Action as we have now 2 actions already created in standard :
    But when we try the SEND_MAIL_CHANGE_MANAGER one with the following action definition :
    with schedule condition :
    and start condition :
    SCOT / SO16 / BP are properly configured based on the following thread ChaRM: Approval Settings - Email Functionality in Change Request
    No email are triggered when for instance the status is in "validation". Are we missing something ?
    Thank you in advance.
    Kind Regards.

    Hi Vivek,
    Thanks for the answer.
    Of course, I have the corresponding YMCR actions created.
    As it is "scheduled automatically", don't I have some kind of WF or jobs to plan ?
    I assume that is not activated by  default once you are in SP 10, isn't it ?
    Based on the TJ30 table, my manager should received an email once the RfC is on "To be approved" or "Being implemented" status....which is not the case today...
    As I am using the same user for testing the flow, I am wondering if it doesn't come from that but I doubt it.
    And again, I wonder if there is not configuration to activate for these 2 actions, don't you think ?
    Thank you in advance for your answer.

  • Change Notification with C#

    I am trying to get a test application to work using Oracle Change Notification with C#, but I am not receiving the callback notification in my application. Oracle DB version is 11.2.0.1.0. Oracle.DataAccess v.2.112.30. I can confirm the query gets registered in Oracle by viewing SYS.USER_CHANGE_NOTIFICATION_REGS and SYS.USER_CQ_NOTIFICATION_QUERIES. However, nothing ever appears in SYS.DBA_CHANGE_NOTIFICATION_REGS.
    The registration persists until I commit a transaction on the table. The registration disappears after a few seconds after the commit and my application does not received the notification.
    I have made sure my computer is listening on the correct port and have even tried turning off any firewall that could be blocking the port.
    I do have GRANT CHANGE NOTIFICATION to MYSCHEMA, GRANT EXECUTE ON DBMS_CHANGE_NOTIFICATION TO MYSCHEMA, and the JOB_QUEUE_PROCESSES is set to 1.
    Questions:
    1) Should the registration be visible in SYS.DBA_CHANGE_NOTIFICATION_REGS and, if so, what could be causing it not to be when it is visible in SYS.USER_CHANGE_NOTIFICATION_REGS and SYS.USER_CQ_NOTIFICATION_QUERIES?
    2) What could be causing the registration to disappear after a commit?
    3) What could be causing the failure of the notification to my application?
    Here is the C# code I am using and it is basically the same as from the Oracle website:
    using System;
    using System.Threading;
    using System.Data;
    using Oracle.DataAccess.Client;
    namespace NotifyTest
    public class Program
    public static bool IsNotified = false;
    public static void Main(string[] args)
    string constr = "User Id=mySchema;Password=myPassword;Data Source=myOracleInstance";
    OracleDependency dep = null;
    try
    using (var con = new OracleConnection(constr))
    Console.WriteLine("Registering query...");
    var cmd = new OracleCommand("select * from mySchema.NOTIFY_TEST", con);
    con.Open();
    OracleDependency.Port = 1005;
    dep = new OracleDependency(cmd);
    dep.OnChange += OnMyNotificaton;
    int queryRegistered = cmd.ExecuteNonQuery();
    // If oracle returns -1, then the query is successfully registered
    if (queryRegistered == -1)
    Console.WriteLine("Query Registered...");
    Console.WriteLine("Listening for Callback...");
    else
    Console.WriteLine("There was an error...");
    catch (Exception e)
    Console.WriteLine(e.Message);
    // Loop while waiting for notification
    while (IsNotified == false)
    Thread.Sleep(100);
    public static void OnMyNotificaton(object sender, OracleNotificationEventArgs arg)
    Console.WriteLine("Table change notification event is raised");
    Console.WriteLine(arg.Source.ToString());
    Console.WriteLine(arg.Info.ToString());
    Console.WriteLine(arg.Source.ToString());
    Console.WriteLine(arg.Type.ToString());
    IsNotified = true;
    }

    Just wanted to provide an update as to how I resolved this issue. I changed my Oracle.DataAccess.dll from v.2.112.3.0 to v.2.112.1.2 and it works fine.

  • Issue with PO Response in SRM 7.0

    Hi Experts,
    We have upgraded our system from SRM 4.0 to 7.0. Post upgrade we are facing an issue with PO Response document.
    Scenario:
             When the PO is ordred, Vendor sends a the PO response through XML. Our middleware call the an FM which uses BBP_PD_POC_CREATE to create the PO response(BUS2209) with acceptance status.
    Problem:
            The status of the PO response is always + In Process+. But in SRM 4,0 we are having the responce with accepted status.
    Could you please throw somw light on this.
    Thanks in Advance,
    Vishnu Reddy

    There is this note that might help you.
    Note 1393346 - PCO:Header status is open, even all items in PCO accepted
    Although a relatively new note, this note is only relevant for SRM5.0 at the moment. What I'd suggest you do is to (temporarily) modify the standard code (in your development or test system) based on the correction instruction of this note. If it resolves your problem, create an OSS mesasge to SAP and ask them to upport the note to SRM7.0. Then you could reverse your modification back to standard and apply the note officially.

  • Integrate KDE notifications with Openbox?

    Hi,
    I'm using openbox with whole set of KDE programs (I prefer it this way over KDE with OB as WM).
    Is there any way of integrating KDE notifications with OB to make it look neat?
    Cheers
    vi3dr0

    What do you mean "integrating KDE notifications with OB" ?
    If it's related to launching KDE applications from OB menu, you can have entries like that :
    <menu id="apps-editors-menu" label="Editors">
      <item label="Kwrite">
        <action name="Execute">
          <command>kwrite</command>
          <startupnotify>
            <enabled>yes</enabled>
          </startupnotify>
        </action>
      </item>
    </menu>
    in your ~/.config/openbox/menu.xml
    If it's something else, explain and give an example of what you want.

  • They sent me a serial number for a windows version of PS Elements when I ordered a mac version.  The serial number doesn't work, not surprisingly, but they don' t seem to care.  I have tried the chat line and have waited for almost a day with no response.

    They sent me a serial number for a windows version of PS Elements when I ordered a mac version.  The serial number doesn't work, not surprisingly, but they don' t seem to care.  I have tried the chat line and have waited for almost a day with no response.  What should I do?

    Look here
    Order product | Platform, language swap

  • Error with universalis responsive template. Prices appear with 163; code before them instead of £ sign. Does anyone know how to fix this problem?

    Error with universalis responsive template. Prices appear with 163; code before them instead of £ sign. Does anyone know how to fix this problem?

    Error with universalis responsive template. Prices appear with 163; code before them instead of £ sign. Does anyone know how to fix this problem?

  • Is it ok to have a interactive notification with an action , which initiates a phone call

    Is it ok to have a interactive notification with an action , which initiates a phone call

    BPerlman wrote:
    1.  I can't choose fixed point representation when I have a dial or knob control.  the "FXP" option is disabled.
    2.  The help tells me to set the range and desired delta, but they seem to be read only!
    3.  Why do you suggest a range of 0..1 and multiply by 360, rather than a range of 0..360 in the first place?
    Interesting. I wasn't aware if this limitation. I guess it only works for simple controls. (Here's an idea!)
    You cannot set the range and delta, they are the results of the "word lenght" and "integer word lenght". These are tightly limited by the underlying binary representation.
    In this particular case, you could chose a word lenght of 12 bits and integer word lenght of zero bits, giving you an increment of exactly 1/4096 (The display is unfortunately rounded to four decimal digits and does not show the full resolution) (Here's another idea!)
    LabVIEW Champion . Do more with less code and in less time .

  • Status ORAS in notification with no order created

    I have some notifications with status ORAS (order assigned) but no PM order created (the field is blank). I am trying to fix the inconsistency with no sucess. I get a dump whatever I do in the notification.
    thanks

    Hi,
    You can use report ZREPNOT2 from note [375789|https://service.sap.com/sap/support/notes/375789] to remove the incorrect ORAS status. Report can be used on all current releases.
    -Paul

  • Thread pool with AT MOST one thread at a time

    Hi,
    I want to create a pool that creates at most one thread when it is needed. I want the pool to terminate the thread when it is idle for some time. Executors.newSingleThreadExecutor() creates a thread pool with one thread, but this thread doesn't die if idle...
    The code below also doesn't work - no thread is ever created:
    new ThreadPoolExecutor(0, 1, 30, TimeUnit.SECONDS,
                              new LinkedBlockingQueue<Runnable>());Thanks in advance

    Use Future.get().
    package net.jcip.examples;
    import java.util.concurrent.*;
    import static java.util.concurrent.TimeUnit.NANOSECONDS;
    * RenderWithTimeBudget
    * Fetching an advertisement with a time budget
    * @author Brian Goetz and Tim Peierls
    public class RenderWithTimeBudget {
        private static final Ad DEFAULT_AD = new Ad();
        private static final long TIME_BUDGET = 1000;
        private static final ExecutorService exec = Executors.newCachedThreadPool();
        Page renderPageWithAd() throws InterruptedException {
            long endNanos = System.nanoTime() + TIME_BUDGET;
            Future<Ad> f = exec.submit(new FetchAdTask());
            // Render the page while waiting for the ad
            Page page = renderPageBody();
            Ad ad;
            try {
                // Only wait for the remaining time budget
                long timeLeft = endNanos - System.nanoTime();
                ad = f.get(timeLeft, NANOSECONDS);
            } catch (ExecutionException e) {
                ad = DEFAULT_AD;
            } catch (TimeoutException e) {
                ad = DEFAULT_AD;
                f.cancel(true);
            page.setAd(ad);
            return page;
        Page renderPageBody() { return new Page(); }
        static class Ad {
        static class Page {
            public void setAd(Ad ad) { }
        static class FetchAdTask implements Callable<Ad> {
            public Ad call() {
                return new Ad();
    }

Maybe you are looking for

  • Load balancing URL setup for planning application 11.1.2.1

    Hi Gurus, There is an existing planning environment with Weblogic/ Oracle HTTP load balancing setup. I just would like to know where would exactly be the generic/ common URL (the URL without actual servername) configured for planning and SmartView? I

  • IBM WEBSPHERE EXCEPTION

    I'm getting the following exception while starting the IBM websphere server administrator's console: Exception: Namecom.ibm.ejs.sm.exception.AttributeNotSetException: Name      at com.ibm.ejs.sm.beans.Attributes.getGeneric(Compiled Code)      at com.

  • Install of Win 7 will not continue.

    Hello there, I want to install Windows 7 via Boot Camp and using a MacbookPro (about 14 month old). What I have here is the Install CD of Win 7, Mac OSX Snow Leopard and some Version of Bootcamp. Here is the first problem, I can`t find the informatio

  • Adding security permission in java.policy

    Hi All, I need to set security permissions for applet. How we can add security permission in java.policy at runtime in java? Thanks in advance. Rakesh Kashnia

  • Unable to reinstall CS5 on OS 10.5.8 "not supported on this architecture."[was: Tim]

    trying to reinstall CS5 on OS 10.5.8. Program was uninstalled but when I try to reinstall I get "can't open application "install" because it is not supported on this architecture.