How to Synchronize two methods or more methods

HI All,
As a java starter in learning Synchronization. how simply can I Synchronize two methods
for example I have the following.
public class Process {          
public static void main(String args[]){
process1();
process2();    
private void process1(){
private void process2(){
}

A-KADRI wrote:
HI All,
As a java starter in learning Synchronization. how simply can I Synchronize two methods
for example I have the following.
public class Process {          
public static void main(String args[]){
process1();
process2();    
private void process1(){
private void process2(){
You're being really ambiguous. You could "synchronize" those methods by adding the synchronized keyword to their method signature, in which case they will implicitly lock on the object they belong to. That's what most people will think you mean when you say synchronized. Is that what you meant? Or did you mean what BDLH was thinking in that you wanted to lock something, then do 1,2,3,4, then unlock it? That's something different. Be specific!

Similar Messages

  • How to synchronize two database in ur java program

    Hi All
    How to synchronize two data base of mysql using java programing language?
    If somebody has any idea that will help me a lot.
    Thanks and regards
    Srikant

    Of corse I have an idea, but not good!
    If you know the database stucture then copy data from one to another.
    Open 2 connections: one to source and one to dest.
    And:
    String sql = "SELCET * from mytable1";// from source
    string sql2;
    Statement st1 = connSrc.createStatement();
    Statement st2 = connDest.createStatement();
    ResultSet rs = st1.executeQuerry(sql);
    while(rs.next()){
    sql2 = "INSERT INTO mytable1 ('field1', 'filed2') VALUES ("+
    "'"+rs.get(filed1")+"',"+
    "'"+rs.get(filed2')+"'"+
    st2.executeUpdate(sql2);
    // the destination was cleared before this: DELETE FROM mytable1 WHERE 1
    This is a mysql sample without processing the errors.
    Szabi

  • How to synchronize two fpga DIO?

    Hi!
    I am using two FPGA 7962R (flexrio) with each 6581 terminal board in PXIe-1082 chassis. My problem is how to synchronize two 7962R digital output with PXIe-1082 chassis backplane signal Dstar* or Clk10 or DAQ signal.
    Actually I tried the synchronization with one DAQ counter clock (confering 'Gen Dig Pulse Train-Finite_NI. vi') , and get the signal PXI-Trig0 by source terminal and target terminal connection, but that one does not work properly. Especially, one trigger signal in HOST to set the starting point of each FPGA (7962R), make error by depending on the trigger signal value(Hz value and Timed loop clock in FPGA vi). It was very tricky and not reliable. (I am attaching figure files as explaining the situation)
    My aim is simply to use two FPGA 7962R Digital output as one FPGA, for controling X-axis, Y-axis with each FPGA, while able to change each FPGA (X-axis, Y axis) digital output value. Because the synchronization is not correct, X,Y axis control with Two FPGA currently is out of target if I use simply while-loop design in HOST and timed-loop design in FPGA vi. What is correct design to synchronize the two FPGA 7962R without using PFI line, only with PXIe-1082 chassis backplane signal and able to change the digital output value? Please let me know any idea for HOST vi, FPGA vi programming.
    Many Thanks
    Attachments:
    host1.png ‏47 KB
    fpga1.png ‏131 KB

    Posted response to this in the following thread:
    http://forums.ni.com/t5/Real-Time-Measurement-and/synchronization-two-fpga-7962r-digital-output/m-p/...
    Patrick H | National Instruments | Software Engineer

  • How to Compare Two Strng without .equals() method

    Hiii,
    How to compare two Strings with out .equals method if there are white spaces in between these string it should be avoided..
    eg: ab cd ef g is equal to a bc de fg
    Please give me the logic or code..
    Your help will be appreciated

    dude find the code without the equal method
    public class test {     
         public static void main(String args[])
              String str = "ab cd ef g" ;
              String str1 = "a bc de fg";
              char []ch = str.toCharArray();
              char []ch1 = str1.toCharArray();
              int counter =0, counter1 = 0;
              while(counter < ch.length && counter1 < ch1.length)
                   while(ch[counter]==' ')
                        counter++;
                   while(ch1[counter1]==' ')
                        counter1++;
                   if(ch[counter] != ch1[counter1])
                        break;
                   counter++; counter1++;
              if(counter == ch.length && counter1 == ch1.length)
                   System.out.println("true");
              else
                   System.out.println("false");
    }

  • How to synchronize two USB webcams (each at 30fps) for a combined 60fps video? Three for 90fps?

    Hello All,
    Multiple-Camera Lab Application: How-To?
    Exploring a loose-synchronization for cameras, low resolution, B&amp;W=gray video capture, that may require up to 200fps, laboratory application.
    Frames would be recorded serially, from 1_frame/10msec at 100fps to 1_frame/5msec at 200fps.
    Consecutive frame-to-frame intervals do not need to be fixed at 10msec, they may vary a lot +/-50%, are non-critical.
    Video recording may last up to 1_minute maximum real time (no sound recording needed at any time).
    Specs say a generic USB2.0 webcam can record up to 30fps.
    And USB2.0 is a half-duplex serial protocol.
    Using two or more webcams in parallel, focused on the same scene, may yield a composite video capture at multiples of 30fps.And much lower price than a single dedicated high speed camera.
    Ultimately all frames have to be assembled -in sequence- into one big video recording.
    Any comments, any ideas? Did anyone try this?
    Thank you,
    Dan

    Hi,
    Sorry I am not much help about this. Creative webcams aren't built to work that way.

  • How to synchronize two NI9215 DAQmx cards?

    Hi there,
    I'm using two NI9215 DAQmx cards (4ch simultaneous sampling analog inputs) in a chassis type cDAQ-9174.
    Since I need to aquire 8 channels simultaneously I've two NI9215 cards.
    My question is how do I configure these cards to be synchonized?
    I'm using LabVIEW2009 SP1 Dev. Suite
    Thanks for answers!
    Solved!
    Go to Solution.

    One of the beautiful things about CompactDAQ is that you can put multiple modules of the same time (Analog, Digital, etc.) into the same task and they are automatically synchronized.  So, to synchronize the two modules, create one Analog Input task and reference the channels as "cDAQ1Mod1/ai0:3, cDAQ1Mod2/ai0:3".  This will automatically synchronize the two modules together.
    Seth B.
    Staff Test Engineer | National Instruments
    Certified LabVIEW Developer
    Certified TestStand Developer
    “Engineers like to solve problems. If there are no problems handily available, they will create their own problems.”- Scott Adams

  • How to synchronize two Event Dispatcher threads?

    I have two applications running in the same jvm. The flow should go like--
    a) First application (A1) has a swing window containing componets like buttons, text boxes etc.
    b) On click of this button, Event Dispatcher thread (T1) , calls the other application (A2).
    c) The second application A2, creates a swing window using EventQueue.invokeLater method and in the mean time Thread T1 should wait for this new A2 window to get some results from the database.
    Is it possible to stop thead T1 in between without freezing the GUI components of application A2.
    Thanks

    I think what tjacobs01 is getting at, is that there is only one Event Dispatcher Thread per JVM. So your question does not make sense. If there really is two EDT threads, then you are dealing with inter-process communication (since there would be two JVM processes, one for each application).
    It sounds like there is only one JVM, one EDT and two instances of a java.awt.Window. You probably think of the window == an application. In that case, you can probably solve your problem by executing the DB access (the long-running task) in the doInBackground() method of a SwingWorker.
    http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html

  • How to synchronize two scroll bars

    Hi there,
    Can anyone tell me how to go about to synchronize 2 JScrollPanes so that When the Scroll bar of the top Pane is moved, the scrollPane of the bottom pane also moves in sync. Thanks in advance.

    1. get hold of the two scrollbars using getHorizontalScrollBar() or getVerticalScrollBar()
    2. listen to their AdjustmentEvents using
    addAdjustmentListener(AdjustmentListener l)
    3. in the AdjustmentListener set the scrollPosition
    of the other scrollbar, when an AdjustmentEvent gets
    fired. You can use setValue(int)
    Spieler

  • How to synchronize two applications system

    HI,
    I work witj Designer 9i, in a Non-versioned Repository. I create a copy of an application system on the same repository.
    I would like to know if there is some mechanism that will synchronize the two application system copies. What i want is how to automate the replication of any modification I made to the copy, in the original application.
    Thanks for your help,
    Malika

    Hi Roel,
    I want to do this because in our organization the repository is non versioned, and we want to make copies for the application system in purpose to sure that only Data modeler and DBA will access it. The developers can't update it. In the original application system we will replicate the changes and then developers go on with their Treatment modules.
    Thanks for your reply ,
    Malika

  • How to sync two computers (or more) without iCloud?

    i need to sync (or copy) iCal, Notes, Remembers, Adress Book between two computers working on Mountain Lion. How can i do without using iCloud or other cloud?

    You can share files via Airdrop. Not sure if that's what you're really looking for pertaining to a way within the Mac OS.
    http://support.apple.com/kb/HT4783

  • How to synchronize two timer/counter tasks?

    Hi,
    I'm programming DAQmx through the nicaiu.dll with Matlab. I'm trying to start two different tasks, each controlling ctr0 and ctr1, respectively. Both timer/counter tasks should start on a common trigger, in my case /Dev/PFI0. Having searched the forum, I do understand that both tasks can't be triggered off PFI0. Instead, I probably need to trigger one of my tasks on a signal that turns on whenever the first task starts. My question is; What signal can inform my ctr1 task that my ctr0 has started? I basically want these two tasks synchronized, but not pulse by pulse since the pulse trains are quite different.
    Trying to trigger both off PFI0 results in a resource conflict. Triggering ctr1 on ctr0gate doesnt work either.
    Also, I need ctr1 to trigger on when the ctr0 tasks starts, i.e. not when the first ctr0 pulse appaers!
    Thanks,
    Per

    Thanks Ryan.
    I made some changes to my code now and it appears I CAN trigger both counters off PFIO (on an E-Series board). I only recently converted all my Traditional code into DAQmx, and got lost in my tracks. I was trying to generate finite pulse trains on both counters, and had used Finite timing on the counters to generate finite retriggerable pulse trains, without knowing that tied up the second counter. I solved this now using Pause Triggers instead. In the case where I generate single retriggerable pulses I still use a Start Trigger, and I can now Start BOTH counters using DAQmxCfgDigEdgeStartTrig and listening to PFIO with both counters (each counter running off a separate task).
    Sorry, I got things confused, and your solution isnt required anymore. Similarly to your solution, though, I have always used a (real) analog output routed externally to the PFI0 pin on my E-Series board as the synchronizing trigger. However, if I could avoid the external wiring it would be nice, so I will explore your solution a bit more
    I am not familiar with the concept of a 'dummy' task/channel. Can you point me to more documentation on this?
    I already use the analog inputs on this board from another app. Will creating a dummy AI tie up all analog inputs, so I can't then access my physical analog inputs from other applications (on the same board)?
     - Per

  • How to synchronize two PCI-6602 via RTSI for semi-period counting of four signals?

    Hello,
    I try to measure 4 PWM signals. For that, I created 4 tasks (newest DAQmx), each with semi-period measuring one signal.
    I want to use DMA so I have two 6602 for each two signals.
    The task aquire a finite number of samples.
    This works fine when starting the tasks subsequently.
    Now I want to start the tasks via a trigger on the RTSI bus.
    But I have no idea how to get this done.
    I use the MX drivers for the first time an find it very difficult to get through the help files.
    I looked at many examples but did not find a solution.
    Most of the time my experiments end with an error message saying that the property is not applicable to this task, or s.th.similar.
    Ans sometimes, when there seems to be a trigger defined, the task will not wait for the trigger and time out.
    Is the anybody who can help me out of this?
    Maybe a little sample program?
    I program in CVI.
    Many Thanks
    Michael.

    This topic is discussed here:
    http://forums.ni.com/ni/board/message?board.id=250&message.id=13383&requireLogin=False
    Hope this helps!

  • How to synchronize two flash in an html page?

    I've placed two seperate flash on my page but i want them to
    be played at the same time. but how?
    One idea is that one of the flashes sends some data to
    another. But i don't know how to do it by actionScript.
    By defult these two are not loaded at the same time
    Happy new year

    Hello! I try input a .swf file in my homepage, but it doesn't
    work. Can anyone know what would be the problem?
    The link is:
    www.e-promo.hu
    The swf must be at the bottom of the page...

  • How to synchronize two different oracle designer repositories

    Hi
    we have the following situation
    we use Oracle designer and SCM repsository to manage our datamodels and server models.
    we have two teams working in two different locations. Both teams are working on the same datamodels/ server models.
    issue is , the network speed is slow between the two locations, so we dont want to use same instance of SCM repository (or in other words same oracle database server) to manage work.
    is there a way/Tool , whereby Both teams can work in separate repositories at their respective locations (i.e. on two different oracle servers ) and we keep transfering the changes (deltas) between two repositories to keep them in sync ?
    Tia and Regards

    You might be able to use a database link to connect from one db to another.

  • How to synchronize two J2ee instances ??

    Dear all,
    I have just installed a second j2ee instance(server2).
    Hhow can I guaratee that both instances will have the same deployment aft5er starting server2. Can I use server1 for maintenance (importing new developments),after that starting server2 and both have the same content.
    Best regard
    Wolfgang

    Hi Wolfgang,
    The synchronization between Portal nodes is done automatically by the engine.
    An easy and short way to verify the synchronization may be to compare the content of a single end-user on both servers.
    Assign user X to a role, make some changes\personalizations, login to the other server node with the same user X and make sure chages are reflected on all nodes.
    Hope this will help.
    Kind regards,
    Aviad

Maybe you are looking for

  • Running Aging reports based on Document date in 2007

    Hi All, I have an issue while running the Receivables aging report in the 2007 version. The customer usually runs the reports based on the document date. Document date holds more importance in their case. However, in the 2007 version, the aging repor

  • Can't import with "Do not import duplicates"  checked

    When I import photos from my camera, I always use Do Not Import Duplicates/Apply to All. Lately, however, when I do this, the import stalls- the progress bar goes gray, and nothing happens. I have to Cancel, then start the import again, and import al

  • Can't get rid of jagged edges of aligned objects

    I have the annoying problem of jagged edges on aligned objects in Illustrator. This image demonstrates it well: http://i.imgur.com/AIyK6vK.png You can see the white background shining through where objects align to each other. I thought this was only

  • Passing polymorphic ArrayLists to a method expecting ArrayList superclass

    In short, is it possible? In keeping in line with my other threads and a program using cats, I give you this example using Cats and Animals (a cat is an animal): public void go()      ArrayList<Cat> lotsOfCats = new ArrayList<Cat>();      feed(lotsOf

  • Sync boss rc50 to Logic (tempo)

    Hi, I've searched around with no luck so thought I would try here. I have a Boss RC50 looper and would like to sync it to Logic.  In Logic, I setup Midi Clock in the synchronization section and RC50 is set to receive midi.  I have a Motu Tiempiece an