Read a same file concurrently by several threads

Can anyone show me how to open and read a same file "concurrently" by several threads?

You'll have to be more specific. Which part do you not know how to do? Do you know how to open and read a file? Do you know how to create multiple threads? Also, are all threads reading the file from start to end, or is each thread going to read a different part of the file, to either be combined after all are done or processed independently?
Please be more specific about what you're asking and post code showing what you've attempted so far.

Similar Messages

  • Labeling segments of the same file

    I have dozens of short segments (a few seconds to a few minutes in length) in my timeline, all from the same file, which is several hours long and named, say, 20110301. In the timeline each of these dozens of segments is given that same name. Is there a way to label the individual segments so I can tell which is which when I'm shifting them around in the timeline?
    (My workflow thus far is to import the original file into my project, scan through it in the viewer, mark in and out points for a "keeper" bit, hit F10 to dump it into the timeline, then try really hard to remember which is which. Lather, rinse, repeat. )
    Thanks in advance for your help.

    Just an update...
    Making the clips independent didn't seem to do anything, other than to gray out that option in the ctrl+click menu. I think for the original purpose of this thread, labeling segments of the same file, it works as well as subclipping, so both of those answers were helpful, thank you.
    My second challenge (later in thread) of saving just the individual subclips or independent clips and deleting the original file remains unsolved. Media Managing it doesn't seem to be the way to go, as it claims that 45 minutes of footage is 56.5GB in space when the entire original 3 hour file is 60GB.
    Because space saving has now reached a critical point for me, I'm exporting the subclips as a QuickTime movie with the current settings so I can delete the original file and try subclipping the export and saving the individual files later... hopefully my export won't be 56GB!!
    Thanks again for all your suggestions, I'm learning a lot.

  • 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.

  • Several handles to the same database in a single thread

    I have a single-threaded program where several db handles are created with db_create() and they're all opened to the same database in the same file. The handles will be used serially, in quite random order for reads and writes, and each of them will be closed at the end of the program.
    Do I need to take any steps to ensure the integrity of the database? I currently create the handles and open the databases with the default settings, if applicable.

    Guys, I am still racking my brain. I have taken some screenshots to show you how I have my database tables set up. I was able to get the tables over to the InnoDB type so I can make foreign keys. Here is how I currently have them setup, can someone check this out and see if it's correct?
    Table 1 (carinfo)
    Table 2 (images)
    Thanks

  • 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.

  • Mac on Windows SMB Share- IDLK files disappearing allowing several users to access the same file

    Hi,
    We have a volume licensing agreement with Adobe and have around 16 Adobe CS6 licenses all used on Macs. The network is based around Windows servers and shares which the Macs connect to via an SMB connection to the server. The issue we're having is that when an InDesign file is opened, sometimes it will not create an IDLK file (or sometimes it will create one but it will disappear seconds later) and it allows several people to view the same file at the same time. Obviously two or more people working on the same file can, will and has caused issues with overwriting documents without knowledge of doing so.
    Has anyone else encountered this or have any ideas as to what might help us resolve this issue?
    Thanks

    When you open a file from a previous version (you'll see converted in
    the file name) there is no CS6 file in existence, yet. Once the file is
    saved as a CS6 file, the lock file is created. The whole procedure is
    designed so that you must make a fully conscious decision to overwrite
    the old version file with a new one.
    This is no different than creating a new document that hasn't been saved
    yet.

  • How to make several threads do smth at the same time?

    Hello!
    Is there a way to make several threads guaranteedly do something at exactly the same time? The code below creates two identical Random objects with approximately 90% probability, in 10% cases Random's are different (Random constructor takes current system time as its argument). But how to ensure it 100%?
    import java.util.*;
    public class SyncThreads extends Thread {
         static Date DATE;
         static long CURRENT_TIME;
        public static void main(String args[]) {
              DATE = new Date();
              CURRENT_TIME = DATE.getTime();
                    new SyncThreads().start();
              new SyncThreads().start();
         public void run()
              try
                   Date thread_date = new Date();
                   long diff = thread_date.getTime() - CURRENT_TIME;
                            //sleeping untill it's 1 second since the 1st line of main() executed
                   sleep(1000 - diff);
                   int r_i = new Random().nextInt();
                   System.out.println(r_i);          }
              catch (InterruptedException e)
                   System.out.println("Find out what InterruptedException is!");
    }

    and even if the PC has multiple processors you are still not guaranteed that it will run the seperate threads at the same exact moment. The JVM for the platform would have to be optomized to make use of multiprocessors for starters, and even if it is it still doesn't guarantee it, the way the OS handles applications (i.e. the JVM) and the way the JVM handles multithreads all will have implications on whether or not two threads actually truly run simultaniously.

  • Read form file ok, try to write to same file : FileNotFound

    My application starts reads an xml file. When I try to write back to the XML file I get
    javax.xml.transform.TransformerException: java.io.FileNotFoundException: file:\C:\Documents%20and%20Settings\alzoid\My%20Documents\Netbeans%20Projects\Laptop\UserSettings.xml (The filename, directory name, or volume label syntax is incorrect)
    I did SOP for file.getAbsolutePath() before it read and writes and the ouput is the same:
    "C:\Documents and Settings\alzoid\My Documents\Netbeans Projects\Laptop\UserSettings.xml"
    Here is the code that reads (works):
    public void fillToFile() {
            xmlFile = new File(TO_FILE_NAME);
            try {
                if(xmlFile.exists()) {
                    setToPocketPC(db.parse(xmlFile));
                } else {
                    createToPocketPC();
            } catch (SAXException se) {
                       se.printStackTrace();  
            } catch (IOException ioe) {
                ioe.printStackTrace();
        }Here is the code that throws the exception:
    private void writeDocumentToFile(Document doc,String fileName){
           try {
            xmlFile = new File(fileName);  
            System.out.println(xmlFile.getAbsolutePath());
            source = new DOMSource(doc);
            result = new StreamResult(xmlFile);
            transformer.transform(source, result); //fails here
            xmlFile = null;
            source = null;
            result = null;
           } catch (TransformerConfigurationException tce) {
               tce.printStackTrace();
           } catch (TransformerException te) {
               te.printStackTrace();
           } /*catch (IOException ioe) {
               ioe.printStackTrace();
        }The strange thing is I tested the read/write last week and it worked. I did not change any code. If I copy the file:\c:\Documents%20and%20Settings.... Path into windows explorer it finds the file.
    Any suggestions?
    Thanks
    Al

    I'm not sure why either, though the API docs mention "takes File to populate a StreamResult", which really does not make any sense. The File would be populated by the StreamResult. The way it is written would only make sense, at least to me, if the File was being used as input.
    Glad I could help. Best of luck.
    - Saish

  • Issue : Read a text file and print the same

    Hi, My requirement is to read a text file and print it the same way.
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class CatFile {
    public static void main(String[] args) throws Exception
         FileReader file = new FileReader("D:/Test/Allfiles.txt");
         BufferedReader reader = new BufferedReader(file);
         String text = "";
         String line = reader.readLine();
         while (line != null)
              text += line;
              line = reader.readLine();
         System.out.println(text);
    The text file i used contains
    A
    B
    C
    but my output is ABC.
    What change should be made to print it the same way in the txt file ?

    Hi EJP,
    I modified the code based on your suggestion and now its working as expected. Thanks
    Modified code :
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class CatFile {
    public static void main(String[] args) throws Exception
         FileReader file = new FileReader("D:/Test/Allfiles.txt");
         BufferedReader reader = new BufferedReader(file);
         String text = "";
         String line = reader.readLine();
         while (line != null)
              System.out.println(line);
              line = reader.readLine();
              text += line;
    }

  • Adobe reader will not open pdf files I have saved as, or, export as pdf to my desktop (latest Maverick). The same file does open when I am on the source website (i.e. user manuals etc.). Why?

    Adobe reader will not open pdf files I have saved as, or, export as pdf to my desktop (latest Maverick). The same file does open when I am on the source website (i.e. user manuals etc.). Why?

    iMac G4, Mac OS X (10.4.9)
    Make sure you have the latest Adobe Reader installed for your OS.
    http://www.adobe.com/support/downloads/product.jsp?platform=macintosh&product=10
    Did you try using Preview. If you control click on the PDF on your desktop you can use the "open with" option.

  • Pdf file designed using IREPORT tool. when i preview in adobe reader bold fonts displaying correctly,but same file in mozilla adobe plugin displays fonts unbold

    I have designed a report using IReport tool with some text as BOLD, which generates report in PDF format. when i open the file with Adobe Reader IX it opens perfectly.
    but the problem is when i open the same file in mozilla add-on "Adobe Reader 11.0.3.37" and in previous versions it does not displaying the bold fonts.

    Is there a non-confidential example of this PDF that we could view?

  • Reading the same line twice from a file

    I have code which I have to read the same line of a file when I want. Reading the file by line line to an arraylist or a variable is not the thing that I want. I just want to mark a line position in a file and read to start from the position. Random Files uses seek to do this, but I have to convert bytes and parse them into lines.
    Does bufferedreader has some property or another reading method support this?

    mark() and reset() ?
    Read the API docs for a change http://java.sun.com/javase/6/docs/api/java/io/BufferedReader.html

  • 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.

  • I have an issue in Adobe Reader, blurry text with a section of a PDF. Same file works fine on a colleagues PC. Even tried Pro?

    I posted this question on Twitter last week, was asked to check the settings for rendering and this didn't make a difference. I then installed Adobe Acrobat Pro to see if this made a difference but no luck. Finally I was asked to print in B&W but again no luck. One of my colleagues is using Reader and the same file works fine for him. Please help...

    After a week's worth of debugging, I found the issue.
    The Java type returned from the call was defined as ArrayList.  Changing it to List resolved the problem.
    I'm not sure why ArrayList isn't a valid return type, I've been looking at the Adobe docs, and still can't see why this isn't valid.  And, why it works in Debug mode and not in Release build is even stranger.  Maybe someone can shed some light on the logic here to me.

  • Upload Attachements(Doc File) into SAPand Read The same in BADI

    Hi All,
    I am Nagesh, and presently working on a BADI(NOTIF_EVENT_POST) for sending emails when a new Notification is created through QM01 Transaction Code, and its working very very fine. But now an additional requirement has come up, where i need to upload an Standard Format Word Document into SAP and then attach this file to the Mail to which the converted PDF Smartform file has been attached and then send both files in single mail to concerned Vendor. So I tried to upload the .Doc file into SAP by using OAER TCode with following Parameters
    Class name              :            PICTURES
    Class type               :            OT
    Object key               :            CAPA.
    I exactly dont know whether this is the right format or not, please help me, if this is possible or not.
    And also I uploaded the same doc file from application server to Presentation Server using Tcode CG3Z, to a ditectory which exists in SAP (Checked in AL11 Tcode). So the nhow to read that complete file to send the same as attachemnts without making any changes .
    Regards,
    Nagesh Kumar.
    Edited by: Nagesh Kumar on Mar 12, 2010 9:39 AM
    Edited by: Nagesh Kumar on Mar 12, 2010 11:32 AM

    Hi All,
    I am Nagesh, and presently working on a BADI(NOTIF_EVENT_POST) for sending emails when a new Notification is created through QM01 Transaction Code, and its working very very fine. But now an additional requirement has come up, where i need to upload an Standard Format Word Document into SAP and then attach this file to the Mail to which the converted PDF Smartform file has been attached and then send both files in single mail to concerned Vendor. So I tried to upload the .Doc file into SAP by using OAER TCode with following Parameters
    Class name              :            PICTURES
    Class type               :            OT
    Object key               :            CAPA.
    I exactly dont know whether this is the right format or not, please help me, if this is possible or not.
    And also I uploaded the same doc file from application server to Presentation Server using Tcode CG3Z, to a ditectory which exists in SAP (Checked in AL11 Tcode). So the nhow to read that complete file to send the same as attachemnts without making any changes .
    Regards,
    Nagesh Kumar.
    Edited by: Nagesh Kumar on Mar 12, 2010 9:39 AM
    Edited by: Nagesh Kumar on Mar 12, 2010 11:32 AM

Maybe you are looking for

  • External hard drive is still full after deleting files

    I everyone, i really need some help with my hard drive. I have the Lacie 500gb firewire hard drive. I am save most of my short films, and other works on it while using final cut. While rendering videos recently , its said that i needed to free up spa

  • Mac Pro graphics failure

    I have a Mac Pro 1.1 2.0gb dual processor and fitted a ATi5770 card in the spring. Today the machine has developed a serious problem. It appears that the graphics are not being initialised and the monitor remains blank. I swapped out the Ati5770 and

  • I need to know the IMEI of the phone

    hi there, to release my phone with a company in Spain need to know the IMEI of the phone you buy as this that I have was repaired. if anyone can help me to know how to get it would be very grateful. a greeting. david

  • Finder Stability in Windows Network?

    I just set up a network between my old Windows Notebook (Acer TravelMate 800, Windows XP Prof.) and my MacBook (1st Gen, Core Duo). I use a Linksys WRT54GL WLAN router. The MacBook connects via WLAN (WPA2-PSK), the Windows notebook connects via an et

  • Loop Problems. There are no Apple Loops installed on your System.

    When I first open Garage Band I get a message that says "There are no Apple Loops installed on your System. Please reinstall the Apple Loop Package" Where is the Loop Package, how do I reinstall it, and overall.. how do I fix this problem?