Need to understand the relation between ManualResetEvent and thread

please help me to understand the below code
what is resetEvent.Set() and WaitOne() ? what it does ?
var resetEvent = new ManualResetEvent(false);
ThreadPool.QueueUserWorkItem(
arg =>
DoWork();
resetEvent.Set();
resetEvent.WaitOne();
again help me to understand the below code
var events = new List<ManualResetEvent>();
foreach(var job in jobs)
var resetEvent = new ManualResetEvent(false);
ThreadPool.QueueUserWorkItem(
arg =>
DoWork(job);
resetEvent.Set();
events.Add(resetEvent);
WaitHandle.WaitAll(events.ToArray());
why this line WaitHandle.WaitAll(events.ToArray()); is required ?
why adding ManualResetEvent instance to list ?
looking for discussion. thanks

WaitOne() will cause the current (main) thread to wait until the thread pool thread has called the Set() method. If you don't call the WaitOne() method, the code line below ThreadPool.QueueUserWorkItem(...) will get executed before the delegate that you
pass do the ThreadPool.QueueUserWorkItem method has actually finished its execution because the threads are being executed simultaneously:
var resetEvent = new ManualResetEvent(false);
ThreadPool.QueueUserWorkItem(
arg =>
//this will be executed simultaneously on thread B
Thread.Sleep(10000);
//tell thread A to continue
resetEvent.Set();
//thread A waits here until thread B calls the Set() method...
resetEvent.WaitOne();
string s = "abc"; //this line won't get executed until thread B has called the Set() method provided that the WaitOne() method is called by thread A above.
>>why this line WaitHandle.WaitAll(events.ToArray()); is required ?
It causes the main thread to wait until the Set method of all ManualResetEvent objects in the events list has been called. Othwerwise the execution of the main thread would continue immediately after the foreach loop has been executed. By this time the DoWork
method of all jobs has not yet been completed because they are being executed on another thread.
WaitHandle.WaitAll(events.ToArray());
string s = "abc"; //this line won't get executed until all the Set() method of all ManualResetEvent objects in events has been called
>>why adding ManualResetEvent instance to list ?
Because you (appearantly) want to wait for all objects in the list, i.e. you want to wait for the DoWork method to complete for all jobs before you continue the execution of the main thread (and go on to assign the string s to the value "abc"
in the above example).
Hope that helps.
Please remember to close your threads by marking helpful posts as answer then start a new thread if you have a new question. Please don't ask several questions in the same thread.

Similar Messages

  • The Relation between tables and views in oracle financial

    Dears
    I am work in oracle e business r12
    and i need to build report as xml
    when run my select its need big time to view data i have a huge of data so i need to clear the relation of this tables if there is miss and if there another technique in select statement
    this is my select statement
    select
    j_hdr.je_header_id je_header_id,
    hdr.VENDOR_NAME supplier,
    SEGMENT1||'-'||SEGMENT2||'-'||SEGMENT3||'-'||SEGMENT4||'-'||SEGMENT5||'-'||SEGMENT6||'-'||SEGMENT7||'-'||SEGMENT8||'-'||SEGMENT9 Account_number,
    hdr.gl_date gl_date,
    j_hdr.CURRENCY_CODE CURRENCY_CODE,
    inv_lin.DESCRIPTION DESCRIPTION,
    j_lin.ENTERED_DR ENTERED_DR,
    j_lin.ENTERED_CR ENTERED_CR,
    j_lin.ACCOUNTED_DR ACCOUNTED_DR,
    j_lin.ACCOUNTED_CR ACCOUNTED_CR,
    j_hdr.JE_SOURCE JE_SOURCE,
    j_hdr.DEFAULT_EFFECTIVE_DATE Transaction_DATE,
    hdr.INVOICE_NUM INVOICE_NUM,
    QUICK_PO_NUMBER PO_NUMBER,
    null ASSET_CATEGORY_ID,
    hdr.VENDOR_ID VENDOR_ID
    from gl_je_headers j_hdr,gl_je_lines_v j_lin,ap_invoice_distributions dist,ap_invoices_v hdr,ap_invoice_lines_v inv_lin
    where code_combination_id = DIST_CODE_COMBINATION_ID
    and hdr.invoice_id = inv_lin.INVOICE_ID
    and dist.invoice_id = inv_lin.INVOICE_ID
    and j_hdr.JE_HEADER_ID = j_lin.JE_HEADER_ID
    and j_hdr.status = 'P'
    and nvl(:P_SOURCE,'Payables') = 'Payables'
    and je_source = 'Payables'
    and j_lin.CODE_COMBINATION_ID between ( select CODE_COMBINATION_ID
    from gl_code_combinations_kfv
    where CONCATENATED_SEGMENTS = :P_FROM_COMBINATION_CODE)
    and ( select CODE_COMBINATION_ID
    from gl_code_combinations_kfv
    where CONCATENATED_SEGMENTS = :P_TO_COMBINATION_CODE)
    AND TRUNC(dEFAULT_EFFECTIVE_DATE) BETWEEN NVL(:P_FROM_DATE, DEFAULT_EFFECTIVE_DATE) AND NVL(:P_to_DATE, DEFAULT_EFFECTIVE_DATE)
    Thanks in advance

    Welcome to the world of complicated Oracle Application queries. Didn't fully understand your question, so a few guesses -
    I think that you are asking how to make your query faster? I would reference the FAQ section on how to post a question regarding performance.
    Your title indicates you want to understand the relationship between tables and views. In general, Oracle Applications uses views for 2 reasons - to join data from multiple tables for display, and to differentiate data from different organizations. (I am still on 11i and have heard organizations are handled differently in 12 so I can't speak to that for sure).
    To understand the relationship between tables in a view, you can access the view's source code, either through a development tool such as PL/SQL Developer or TOAD (I'm guessing Oracle's tool does this also, but have never used it), or by querying the source from the dba_source table.
    select * from dba_source where name = (name of view) and type = 'VIEW' order by line;without the ( ) just the view name, in all capital letters i.e. , 'GL_JE_LINES_V'
    Good luck!

  • What are the Relations between Journalizing and IKM?

    What is the best method to use in the following scenario:
    I have about 20 source tables with large amount of data.
    I need to create interfaces that join the source tables into target tables.
    The source tables are inserted every few secondes with about hundreds to thousands rows.
    There can be a gap of few seconds between the insert of different tables that sould be joined.
    The source and target tables are on the same Oracle instance and schema.
    I want to understand the role of: 'Journalizing CDC' and 'IKM - Incremental Update' and
    how can i use it in my scenario?
    In general What are the relations between 'Journalizing' and 'IKM'?
    Should i use both of them? Or maybe it is better to deelte and insert to the target tables?
    I want to understand what is the role of 'Journalizing CDC'?
    Can 'IKM - Incremental Update' work without 'Journalizing'?
    Does 'Journalizing' need to have PK on the tables?
    What should i do if i can't put PK (there can be multiple identical rows)?
    Thanks in advance Yael

    Hi Yael,
    I will try and answer as many of your points as I can in one post :-)
    Journalizing is way of tracking only changed data in your source system, if your source tables had a date_modified you could always use this as a filter when scanning for changes rather than CDC, Log based CDC (Asynchronous in ODI, Logminer/Streams or Goldengate for example) removes the overhead of of placing a trigger on the source table to track changes but be aware that it doesnt fully remove the need to scan the source tables, in answer to you question about Primary keys, Oracle CDC with ODI will create an unconditional log group on the columns that you have defined in ODI as your PK, the PK columns are tracked by the database and presented in a Journal table (J$<source_table_name>) this Journal table is joined back to source table via a journalizing view (JV$<source_table_name>) to get the rest of the row (ie none PK columns) - So be aware that when ODI comes around to get all data in the Journalizing view (ie Inserts, Updates and Deletes) the source database performs a join back to the source table. You can negate this by specifying ALL source table columns in your PK in ODI - This forces all columns into the unconditional log group, the journal table etc. - You will need to tweak the JKM to then change the syntax sent to the database when starting the journal - I have done this in the past, using a flexfield in the datastore to toggle 'Full Column' / 'Primary Key Cols' to go into the JKM set up (there are a few Ebusiness suite tables with no primary key so we had to do this) - The only problem with this approach is that with no PK , you need to make sure you only get the 'last' update and in the right order to apply to your target tables, without so , you might process the update before the insert for example, and be out of sync.
    So JKM's provide a mechanism for 'Change data only' to be provided to ODI, if you want to handle deletes in your source table CDC is usefull (otherwise you dont capture the delete with a normal LKM / IKM set up)
    IKM Incremental update can be used with or without JKM's, its for integrating data into your target table, typically it will do a NOT EXISTS or a Minus when loading the integration table (I$<target_table_name>) to ensure you only get 'Changed' rows on the load into the target.
    user604062 wrote:
    I want to understand the role of: 'Journalizing CDC' and 'IKM - Incremental Update' and
    how can i use it in my scenario?Hopefully I have explained it above, its the type of thing you really need to play around with, and throroughly review the operator logs to see what is actually going on (I think this is a very good guide to setting it up : http://soainfrastructure.blogspot.ie/2009/02/setting-up-oracle-data-integrator-odi.html)
    In general What are the relations between 'Journalizing' and 'IKM'?JKM simply presents (only) changed data to ODI, it removes the need for you to decide 'how' to get the updates and removes the need for costly scans on the source table (full source to target table comparisons, scanning for updates based on last update date etc)
    Should i use both of them? Or maybe it is better to deelte and insert to the target tables?Delete and insert into target is fine , but ask yourself how do you identify which rows to process, inserts and updates are generally OK , to spot a delete you need to compare the table in full, target table minus source table = deleted rows , do you want to copy the whole source table every time to perform this ? Are they in the same database ?
    I want to understand what is the role of 'Journalizing CDC'?Its the ODI mechanism for configuring, starting, stopping the change data capture process in the source systems , there are different KM's for seperate technologies and a few to choose for Oracle (Triggers (Synchronous), Streams / Logminer (Asynchronous), Goldengate etc)
    Can 'IKM - Incremental Update' work without 'Journalizing'?Yes of course, Without CDC your process would look something like :
    Source target ----< LKM >---- Collection table (C$) ----<IKM>---- Integration table (I$) -----< IKM >---- Target table
    With CDC your process looks like :
    Source Journal (J$ table with JV$ view) ----< LKM >---- Collection table (C$) ----<IKM>---- Integration table (I$) -----< IKM >---- Target table
    as you can see its the same process after the source table (there is an option in the interface to enable the J$ source , the IKM step changes with CDC as you can use 'Synchronise Journal Deletes'
    Does 'Journalizing' need to have PK on the tables?Yes - at least a logical PK in the datastore, see my reply at the top for reasons why (Log Groups, joining back the J$ table to the source table etc)
    What should i do if i can't put PK (there can be multiple identical rows)? Either talk to the source system people about adding one, or be prepared to change the JKM (and maybe LKM, IKM's) , you can try putting all columns in the PK in ODI. Ask yourself this , if you have 10 identical rows in your source and target tables, and one row gets updated - how can you identify which row in the target table to update ?
    >
    Thanks in advance YaelA lot to take in, as I advised I would reccomend you get a little test area set up and also read the Oracle database documentation on CDC as it covers a lot of the theory that ODI is simply implementing.
    Hope this helps!
    Alastair

  • What is the relation between KTOPL and 0CHRT_ACCTS_ATTR? both Chart of Acct

    Hi
    If an R3 field e.g. KTOPL (in datasource 0fi_gl_4)  which is a "Chart of Accout" is extracted a part of 0fi_gl_4 to BI,
    is there the need to separately extract 0CHRT_ACCTS_ATTR & 0CHRT_ACCTS_TEXT which are also "Chart of Accout"
    What is the relation between KTOPL and 0CHRT_ACCTS_ATTR & 0CHRT_ACCTS_TEXT  in R3?
    What is the relation between KTOPL and 0CHRT_ACCTS_ATTR & 0CHRT_ACCTS_TEXT  in BI?
    Thx

    Hi,
    I get these well with examples so let me see if I get your point:
    So in the tranx data the 0fg_gl will be  a value for KTOPL  e.g. 450009 as a G/L Account number? (Values for chart of Acct should be GL Accounts, right?)
    but before this tranx data is loaded, preferrably,  0CHRT_ACCTS_ATTR and 0CHRT_ACCTS_TEXT should have been extracted to BI; and data loaded; and this will be the master data and there should have been in it:
    .._ATTR   -
    .._TEXT
    450009   -
    Petty cash Expenses
    Is my understanding exact?
    Thnx

  • Table that gives the relation between plant and company code

    Hi gurus,
    I actually have plant number and using this plant value i need to get the company code.
    Is there any table that gives the relation between plant and company code. So,that i can get the company code details.
    Thanks in advance.

    Hi Bhanuphani,
    Use  T001K  where BWKEY is the plant
    Reward if useful
    Thanks Arjun

  • What is the relation between UTXJ and JMOD, how JMOD determine in order

    Hi All,
    What is the relation between UTXJ and JMOD! 
    How JMOD determine in order! ( For TAXINJ).
    Please help me
    Regards
    raj

    Dear Raj
    Both are not related in anyway.  UTXJ is for sales tax and JMOD is for excise condition.  For UTXJ, you need to create a tax code in FTXP and assign it in VK11 / UTXJ, whereas, JMOD is an excise condition type for which, you need to maintain the relevant datas in J1ID.
    Coming to your question, how JMOD is determined in sale order, it is based on delivering plant.  This delivering plant, as already said above, you will have to maintain in J1ID with the indicator "1" under declared tab in Material Chapter ID combination.
    thanks
    G. Lakshmipathi

  • How to find the relation between PAY_ELEMENT_TYPES_F and GL_CODE_COMBINATIO

    Hi, could someone tell me how to find the relation between PAY_ELEMENT_TYPES_F and GL_CODE_COMBINATION tables
    that is because as you could know PAY_ELEMENT_TYPES_F holds the definitions of elements in Oracle HRMS and i need to find the accounting code of each element.
    Thanks

    Hi;
    Please check e-trm site for table relation,integration,explanation etc..
    etrm.oracle.com/
    Regard
    Helios

  • I understand the difference between imessage and SMS but when I text a friend who always got iMessages in the past, everything I send her is SMS (green) even if we both have wifi. She has an iphone.

    I understand the difference between imessage and SMS but when I text a friend who used to receive imessages (blue), my phone shows I'm sending her SMS (green) messages. No longer are they blue. She has an iphone and this happens when we are both connected to wifi. We have both recently updated to ios7. Thanks!

    Turn off iMessage
    Reset Network Settings
    Turn iMessage back on

  • Can any one explain me the relation between BDC and reports events?

    hi experts.....
    can any one explain me the relation between BDC and reports events? we are using report events in BDC programmes why?\
    Is reports events occurs in each and every concept in ABAP i.e creating custom idocs, smart forms, sap scripts, dialog programmes, module pool technics?
    thanks in advance

    The forums are expert forums. So the first thing I would do is change your name.
    It's like entering a grand prix in a car with a "Student Driver" sign.
    Rob

  • Alright understand the dif between forms and designer...but

    alright understand the difference between forms and designer...but I learned forms 6i and reports 6i and want to work in the industry under designer 6i. can i do this? would going into designer 6i be difficult with forms 6i/pl/sql experience??

    Its a different tool with a different type of development.
    You can take an Oracle Designer course or read the docs and start learning.

  • What is the relation between bw and netweaver

    Hi all
    what is the relation between bw and netweaver? any one give answer for this

    Hi
    SAP NetWeaver
    The SAP NetWeaver technology platform is the open integration and
    application platform that reduces total cost of ownership (TCO) across the
    entire IT landscape.
    SAP NetWeaver integrates and aligns people, information, and business
    processes across technologies and organizations
    And BW is a part of Composite Application framework for Information Integration
    This framework also contains Other Components such
    o     Enterprise Portals (EP)
    o     Exchange Infrastructure (XI)
    o     Master data management (MDM)
    o     Solution manager
    o     Web Application server (WAS)
    o     xApps
    Hope this solves ur question.as if any further doubts
    Sonal...

  • What are the relation between JPA and Hibernate, JPA and TopLink?

    What are the relation between JPA and Hibernate, JPA and TopLink?
    Can JPA instead of Hibernate and TopLink?

    The Java Persistence API (JPA) is the object relational mapping persistence
    standard for Java. Hibernate and TopLink provide an Open source Object-relational mapping framework for Java.
    They provide an implementation for the Java Persistence API. In my opinion, both Hibernate and TopLink provide support to JPA
    and they can also be regarded as the complementary to JPA.
    Let's wait to see other person's opinions.

  • What's the relation between Gain and transmitted power with coverage area?

    what's the relation between Gain and transmitted power with coverage area?
    if we want add coverage area, could we just add antenna's gain only or add transmitted power only?

    That information can be found at: http://www.cisco.com/warp/customer/cc/pd/witc/ao350ap/prodlit/agder_rg.htm

  • What's the relations between BEGIN_BALANCE_DR_BEQ and  BEGIN_BALANCE_DR ?

    hello, these days I am learning gl.
    I'm confused about what's the relations between BEGIN_BALANCE_DR_BEQ and BEGIN_BALANCE_DR if CURRENCY_CODE is a foreign currency and TRANSLATED_FLAG = 'R'?
    the trm describes BEGIN_BALANCE_DR_BEQ as 'Beginning debit balance, base currency'.
    where is the BEGIN_BALANCE_DR_BEQ amount come from?
    where is the BEGIN_BALANCE_DR amount come from?
    thank you very much!
    peter

    I'm not sure exactly what you're asking. The query
    UPDATE WH_T_ITEMS A
       SET BALANCE_QTY =MAX(ITEM_QTY)
    WHERE STORE_ID = V_STORE_ID
       AND ITEM_SERIAL = V_ITEM_SERIAL   ;is not valid Oracle SQL. Aggregate functions like MAX cannot be used in a query like that because Oracle has no idea what you are aggregating by. There is nothing that prevents Oracle from modifying the syntax of the SQL language to allow an aggregate to be used in that manner but there would generally be no reason to extend the SQL language like that.
    You could assign the result of a query that included an aggregate to the BALANCE_QTY column, i.e.
    UPDATE WH_T_ITEMS A
       SET BALANCE_QTY = (SELECT MAX(ITEM_QTY) FROM <<some table>> WHERE <<some condition>>)
    WHERE STORE_ID = V_STORE_ID
       AND ITEM_SERIAL = V_ITEM_SERIAL   ;As I believe I've mentioned in some of your previous threads, a data model where you have an ITEMS table that has both an ITEM_QTY and BALANCE_QTY seems suspect. The fact that you're assigning the value of the ITEM_QTY column to the BALANCE_QTY on the same row only increases the concern.
    Justin

  • Technically, what's the relation between FlexUnit and FB?

    I'm running into many small but annoying issues when trying to do FlexUnit testing in Flash Builder 4, like:
    * FlexUnit is open source but I can't Cltr+click on things like assertEquals() to see what's going on there
    * I visit flexunit.org, click Docs and can't find assertThat() method at all while it's available in FB's code hints (and works)
    * We now have 2 documentation sets, one in the "Using Flash Builder 4" book, one on docs.flexunit.org. Some things are documented here, some others there.
    * API docs aren't even available from Adobe, are they?
    I wonder, what is the relation between FlexUnit itself and the developers working on it (Michael and Brian primarily?) and the support in Flex 4 / Flash Builder? I am not very happy with the current state which has nothing to do with FlexUnit itself (is a very nice testing framework), I just feel that a feature that ships in the quite expensive Premium edition should have a much better integration story.
    It looks like I'm ranting (and I am a little) but mainly I'd like to understand what's going on here.
    Thanks,
    Borek

    Borek:
    I understand your pain and I am sorry. Let me answer some of your questions and provide some answers and suggestions.
    Adobe decided to include FlexUnit 4 in Flash Builder 4, which was great. However, when it comes to the way in which they did so, the way in which libraries are linked and the way to plugin works, we (the FlexUnit team) are only able to provide suggestions. We have no control over the approach and little ability to influence the process.
    So, to be even more direct in my answer, there is no formal relationship between these two teams. What features Adobe chooses to support and the workflow/integration are purely business choices being made by Adobe. FlexUnit is purely a community project without funding or support from Adobe. It continues to evolve as we add new features and integrate contributions. Adobe may choose to increase the level of integration or to adopt newer versions as we proceed, but that is solely at their discretion.
    To that end, we cannot change the way the plugin works, etc. However, we will be posting information for users interested in updating their Flash Builder version with our latest code base (and addressing at least one of your issues) shortly as we prepare for our 4.1 beta.
    * FlexUnit is open source but I can't Cltr+click on things like assertEquals() to see what's going on there
    >>Adobe didn't include the code for FlexUnit in builder, only the library. You can control-click on Flex classes because they shipped both the lib and code. If you do want this functionality, you can download our code, go into the build path/library path of the project, find the place where they link in the flexunit-core libraries and edit the source attachment. That will allow the control-click to work, etc. The code that shipped with Flash Builder is tagged as 4.0.0 in github.
    * I visit flexunit.org, click Docs and can't find assertThat() method at all while it's available in FB's code hints (and works)
    >>I will try to find out why this is not showing up and get it fixed promptly. FYI, the assertThat method is just a wrapper for the org.hamcrest.assertThat from the hamcrest library. For more info and code: http://github.com/drewbourne/hamcrest-as3
    * We now have 2 documentation sets, one in the "Using Flash Builder 4" book, one on docs.flexunit.org. Some things are documented here, some others there.
    >>I don't know what is in the "Using Flash Builder 4" book...if you can point me to a link I will check it out. I have no idea what is there (nor who wrote it) The official documentation site is docs.flexunit.org. It is the only one being maintained/added to by those involved with the project.
    * API docs aren't even available from Adobe, are they?
    >>I doubt it. They don't maintain this material and they don't include it.
    Sorry if this is less than helpful, but I wanted to at least provide you some answers and context.
    Mike

Maybe you are looking for

  • External display resolution changes after returning from display sleep

    I often use an external display as a second screen with my Macbook Pro (OS X 10.8.2)  However, when I return to the computer after the display has gone to sleep, the external display resolution changes when the display reappears.  Then I have to go i

  • Play two different sounds at same time  from Split Keyboard?

    Is it possible to configure the Logic Environment so that one can play or record, from a split keyboard, two different EX24/Audio Instrument sounds on two different tracks AT THE SAME TIME... (and/or: combinations of Audioinstrument + Midi) EG: From

  • Problem in BW system while tranporting a change in a Bex Query

    Hi All, I am facing a problem in BW system while tranporting a change in a Bex Query. Actually on our BW system our Client team works as well. I have done started doing some change in query in dev. I have created bex transportable request I want to t

  • Serious bugs in 10.6.4 with trash and permissions

    Hi i need help to trash my adobe cs4 folders, for some odd reason the trash re appears every time i try to cone my drive via superduper or CCC, no matter what i do it re appears, i fixed the permissions so the administrator can read and write, i empt

  • Problem with 8164A drivers

    Hi, I'm controling a 8164A (Agilent) via GPIB-USB controler. I can send simple GPIB messages to the instrument but I can use correctly the VI release by Agilent to execute fast scanning. Is there somebody who can help me ? Tosty