How to read from and write into the same file from multiple threads?

I need to read from and write into a same file multiple threads.
How can we do that without any data contamination.
Can u please provide coding for this type of task.
Thanks in advance.

Assuming you are using RandomAccessFile, you can use the locking functionality in the Java NIO library to lock sections of a file that you are reading/writing from each thread (or process).
If you can't use NIO, and all your threads are in the same application, you can create your own in-process locking mechanism that each thread uses prior to accessing the file. That would take some development, and the OS already has the capability, so using NIO is the best way to go if you can use JDK 1.4 or higher.
- K
I need to read from and write into a same file
multiple threads.
How can we do that without any data contamination.
Can u please provide coding for this type of task.
Thanks in advance.

Similar Messages

  • How to read the data file and write into the same file without a temp table

    Hi,
    I have a requirement as below:
    We are running lockbox process for several business, but for a few businesses we have requirement where in we receive a flat file in different format other than how the transmission format is defined.
    This is a 10.7 to 11.10 migration. In 10.7 the users are using a custom table into which they are first loading the raw data and writing a pl/sql validation on that and loading it into a new flat file and then running the lockbox process.
    But in 11.10 we want to restrict using temp table how can we achieve this.
    Can we read the file first and then do validations accordingly and then write to the same file and process the lockbox.
    Any inputs are highly appreciated.
    Thanks & Regards,
    Lakshmi Kalyan Vara Prasad.

    Hello Gurus,
    Let me tell you about my requirement clearly with an example.
    Problem:
    i am receiving a dat file from bank in below format
    105A371273020563007 07030415509174REF3178503 001367423860020015E129045
    in this detail 1 record starting from 38th character to next 15 characters is merchant reference number
    REF3178503 --- REF denotes it as Sales Order
    ACC denotes it as Customer No
    INV denotes it as Transaction Number
    based on this 15 characters......my validation comes.
    If i see REF i need to pick that complete record and then fill that record with the SO details as per my system and then submit the file for lockbox processing.
    In 10.7 they created a temporary table into which they are loading the data using a control file....once the data is loaded into the temporary table then they are doing a validation and updating the record exactly as required and then creating one another file and then submitting the file for lockbox processing.
    Where as in 11.10 they want to bypass these temporary tables and writing it into a different file.
    Can this be handled by writing a pl/sql procedure ??
    My findings:
    May be i am wrong.......but i think .......if we first get the data into ar_payments_interface_all table and then do the validations and then complete the lockbox process may help.
    Any suggestions from Oracle GURUS is highly appreciated.
    Thanks & Regards,
    Lakshmi Kalyan Vara Prasad.

  • Concurrently logging into the same file from 2 VMs

    If two processes running in the same machine.
    There is only one file name specified in logging.properties, e.g., test.log.
    VM 1 is logging into file test.log while VM 2 does the same thing to the same file.
    Based on the javadoc of FileHandler, the second vm will create another file
    like test.0.log to logging its data.
    Is that true?
    If true, then, when VM1 stops logging, VM2 starts logging again. Will the new logging messages from VM2 go to test.log?
    Thanks in advance.

    I have tested it out.
    When two applications in two processes logging to the same disk file (e.g. test.log) specified by the logging.properties at the same time, the two processes actually log to two different files: test.log.0 and test.log.1.
    When two applicatoins in two processes logging to the same disk file specified by the logging.properties as test.log at different time, e.g., the first process exits, then the second process executes, there are still two different files
    created for each process: test.log.0 and test.log.1.

  • How to read and write to the same external HDD using Mac and PC

    Hello,
    I am using a mid 2014 MacBook Pro.
    I read somewhere that to write to an external HDD from a Mac, you need to format it in a particular way.
    But this would stop it from being used on my PC. Is there any way I can write to the same HDD from both OSes ?
    Thanks !

    Yes.  Format the HDD to FAT or ExFAT.  It seems best to do that on a PC.
    Ciao.

  • How can I save my data and the date,the time into the same file when I run this VI at different times?

    I use a translation stage for the experiment.For each user in the lab the stage position (to start an experiment) is different.I defined one end of the stage as zero. I want to save the position , date and time of the stage with respect to zero.I want all these in one file, nd everytime I run it it should save to the same file, like this:
    2/12/03 16:04 13567
    2/13/03 10:15 35678
    So I will track the position from day to day.If naybody helps, I appreciate it.Thanks.

    evolution wrote in message news:<[email protected]>...
    > How can I save my data and the date,the time into the same file when
    > I run this VI at different times?
    >
    > I use a translation stage for the experiment.For each user in the lab
    > the stage position (to start an experiment) is different.I defined one
    > end of the stage as zero. I want to save the position , date and time
    > of the stage with respect to zero.I want all these in one file, nd
    > everytime I run it it should save to the same file, like this:
    > 2/12/03 16:04 13567
    > 2/13/03 10:15 35678
    >
    > So I will track the position from day to day.If naybody helps, I
    > appreciate it.Thanks.
    Hi,
    I know the function "write to spreadsheet file.vi"
    can append the data
    to file. You can use the "concatenate strings" to display the date,
    time as well as data... Hope this help.
    Regards,
    celery

  • Import data from few tables and export into the same tables on different db

    I want to import data from few tables and export into the same tables on different database. But on the target database, additional columns have been added
    to the same tables. how can i do the import?
    Its urgent can anyone please help me do this?
    Thanks.

    Hello Junior DBA,
    maybe try it with the "copy command".
    http://download.oracle.com/docs/cd/B14117_01/server.101/b12170/apb.htm
    Have a look at the section "Understanding COPY Command Syntax".
    Here is an example of a COPY command that copies only two columns from the source table, and copies only those rows in which the value of DEPARTMENT_ID is 30:Regards
    Stefan

  • When I try to same an image under the command 'save as' it will only let me save as file types 'firefox document' or 'all files' and when I try to look at them later they dont work. How can I save an image as the same file type it is on the web site?!

    When I try to save an image under the command 'save as' it will only let me save as file types 'firefox document' or 'all files' and when I try to look at them later they dont work. How can I save an image as the same file type it is on the web site?!
    == This happened ==
    Every time Firefox opened
    == I updated to one of the firefox versions (Not sure which one it was)

    Thanks Alex, but sadly I already tried that. Neither .docx or .xlsx files show up in the content list. They both show as a Chrome HTML document so changing how Firefox addresses those doesn't help since it thinks its the same type of file. I don't think I can manually add files into the "Content Type" left side nav.

  • How to stream Webcam and Desktop at the same time?

    Hey Guy,
    I just got a little Problem with  FMLE... I want to stream live during a Game, but I dont know how to stream Desktop and Webcam at the same time ^^. The streaming Platform i want to use is twitch.tv.. the most common Gamin Platform I think...
    I got an IMac i7.
    Pls help me   I dont get how all these ProGamer do it -.-
    Thanks in advance
    Kathi

    You're going to need additional software or hardware.  If you're running a Macintosh, try CamTwist.  It's free and allows you to create virtual "cameras" from just about anything you can see on your computer.  It's a bit clunky getting used to the interfact and how it works, however.
    Hardware solutions (like scanline converters and video switchers) can get pretty expensive.  So you may want to go with a piece of software that can handle on-the-fly video compositing/switching.  There are two applications that come to mind right off the bat -- and lucky for you, both of them can also output to a live streaming server. 
    Wirecast is a popular choice, although the pricing starts around $500.  It's Macintosh/Windows.
    A very popular choice among gamers is XSplit (Windows only) and is a subscription-based model (you pay a small fee by the month, quarter, or year).  XSplit has some very impressive compression happening under the hood, and was originally designed for gamers who wanted to share their desktop, XBOX, or PS3 adventures... all while also being able to lay over banners, PIP (picture-in-picture) of themselves, or anythhing else they wanted to clutter the screen with.
    If you're running on Windows, give XSplit at shot.  It can easily handle your desktop (or most anything else) as a "camera" as well as being able to lay your webcam on top of the desktop feed.

  • How do my wife and i use the same ipad?

    How do my wife and i use the same ipad?

    Nothing keeps you from handing it "back and forth" to share. I do this all the time on our couch with my Wife's iPad...
    I think your quesiton revolves around having your own bookmarks and other data/info on the device. 
    The iPad is meant to be a "single user device"; there isn't a login/logout to differenciate one user from another.  "The iPad isn't a computer"..  ;-)
    But, that being said, there are lots of ways to share the iPad/iOS environment.  Many apps, such as Facebook, let you login and out..  so, while you share the same app, each of your login is different.
    For bookmarks and notepad it is a little trickier..  You can each use a different browser (so all of your bookmarks are complerety seperate.)
    In some cases I would sugest a couple get a $900 Macbook Air rather than an iPad if this sharing won't work.  "Why can't I log in and out of and iPad?".  I think that the fact that it doesn't gives the iPad many adantages over a computer.
    If you have more specific questions pleaser ask away.  Just like you share the kitchen table and many other things around your household, there are many ways to make this work!  ;-)
    Matt

  • How to post aquisition and depriciation at the same time

    Hi Gurus,
    Could you please let me know how to post aquistion and depriciation at the same time.

    Hi
    What do you mean by postin at a time, is it uploading the balances to SAP
    if not there is no question of posting at a time
    Thanks
    Kameshwar Rao

  • HT3678 If I download a .mov file from gmail, I am not able to open the file. I reinstalled QuickTime 7.6.6, still unable to open the file. If I download the same file from another mail server I have no trouble. What is gmail doing to my file?

    If I download a .mov file from gmail, I am not able to open the file. I reinstalled QuickTime 7.6.6, still unable to open the file. If I download the same file from another mail server I have no trouble. What is gmail doing to my file?

    Also i have reinstalled the reader9 two  times and tried with reader8 also but in both the cases same problem.
    it would be gr8 help if someone can help.

  • I need to make Landscape and portrait in the same file ? plz I don't want to go back to word

    Hi there I am trying to have page in landscape and portrait in the same file, but I couldn't, however, if there is a way where we can perform it please advise me as I need to do that for my thesis. Am happy to work only in pages if this feature is not in pages, please find us a solution.
    Regards
    Mohammed

    Export te document to PDf. Open it in Preview. Here you can rotate the a page to horisontal.

  • How do I read and write on the same CAN Port

    I have a PXI chassis with a NI PXI 8464 CAN card.  I am learning to use this device.  I am trying to send messages back and forth between the two ports on the card.  I have four simple VIs:ReadWas; WriteWas;ReadSteering; and WriteSteering.  I have been starting the read VIs first then starting the write VIs.  When I start the write VIs I get an error from CAN init saying I am trying to change an object that is running. 
    Is it possible to send and receive on the same port of the CAN card without stopping then reinitializing the card?
     I have attached ReadWas, ReadSteering and WriteSteering to this post.  ReadWas and WriteSteering share a CAN port.
    Any help is greatly appreciated,
    Thanks,
    Phillip
    Attachments:
    ReadWAS.vi ‏112 KB
    ReadSteering.vi ‏143 KB
    WriteSteering.vi ‏114 KB

    have you looked at this example, (CAN Send & Receieve using NI-CAN Frames) it is in the example code section 
    http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=E993D9B56C3D2BABE0340003BA230ECF&p_...
    http://sine.ni.com/apps/we/niepd_web_display.DISPLAY_EPD4?p_guid=E993D9B56C3D2BABE0340003BA230ECF&p_...
    Basically, you are getting the error because the second time you call CANconfig it realizes it is already open. Try consolidating the 2 pieces of code into 1 CAN VI.

  • I would like to know how to insure that all track from a CD I rip into i-tunes all go into the same file regardless of the artist on the CD. I was recdently importing an All Time Low CD into i-Tunes for my daughter and because one track featured a guest a

    i would like to be able to insure that when i import a CD into i-Tunes that all tracks from that CD go into a single file for that album in their proper order regardless of whether or not there is a featured artist on one or two tracks or whatever. i recentl;y imported an All Time Low CD into i-Tunes for my daughter and because one song featured a guest artist i-Tunes placed that song in a seperate folder and so when i synced my daughters i-Pod Touch that one track is not with the rest of the tracks form the album and has to be listened to seperately. The song is from the same album and should be where it belongs with the rest of that album so she can listen to the entire album with the tracks in the proper order. I am sure that this can be done i just don't know how.

    Edit the Name of the problem song to Name [Feat. Guest]
    Change the Artist of that song to All Time Low
    marley2012 wrote:
    ... and i want to make sure that from now on all songs from any CD I import into i-tunes all go into the same album file if they are on that album originally. i do not want i-tunes seperating songs from my CD's for any reason. hopefully this is more clear.
    What you want cannot be done. iTunes has its quirks, and the above is the kind of workaround needed to make the media display sensibly on any device. The article I pointed you to has others that you may find useful in future.
    tt2

  • How do I keep my Cox mail and MSN mail from all going into the same in box on Apple mail

    I have a Imac and Mac Book.  The Imac apple mail works great.  I also have a Mac Book.  The Apple  Mail is set up the same as the Imac.  The problem I have is that both Cox mail and MSN mail go into the same inbox on Apple Mail on the MacBook even though the accounts are separte.  From what I see, the settings are the same as the Imac. I tried to reinstall the apple mail.  No luck!  Should I try again.  Any ideas?

    Go to settings>iclod>then mark "no" in  "contacts" .

Maybe you are looking for

  • Shutdown script for awesome wm

    I`m writing a shutdown script for my awesome wm. it looks like this [c!/bin/bash ACTION=`zenity --width=90 --height=200 --list --radiolist --text="Select logout action" --title="Logout" --column "Choice" --column "Action" TRUE Shutdown FALSE Reboot F

  • Which course is better to learn??

    Hi, I am working as a ABAP developer since 1 year 6 months . i want to learn something related to ABAP. Please guide me which is having good future. i know java fundamentals.. Regards, sri

  • BootCamp fails after installation of Windows 7 Ultimate 64bit

    So guys , as we know loads of people had same issue i been searching it for whole day and couldnt get any answer. First i have installed Windows XP home 32bit sp3 whole computer worked like charm. Today i have deleted xp did re partition installed Wi

  • Font style changes when making a book in iphoto

    I am trying to make a book and the inner cover I wrote a little about our vacation. I wanted to make the font size larger so I clicked on the settings button below and this window popped up with "cover title:" "Cover Subtitle:" etc with the font styl

  • 3gs not working after factory reset

    restored factory settings and now have apple logo on screen and phone is doing nothing please help