Java MULTITHREADING - when multiple threads accesses the print method - why the execution of while method is by default synched
<p>Have a doubt in multithreading.
Following is my main program to access a file, am creating 10 threads to be accessed on the object.</p>

<pre><code>public class CallTest {
    public static void main(String[] args) throws Exception {
        Test t = new Test();
        for (int i = 0; i &lt; 10; i++) {
            Thread t1 = new Thread(t);

            t1.start();

        }

    }
}
</code></pre>

<p>Following is my program to read data from file.</p>

<pre><code>public class Test implements Runnable {
    static int i;
    public void run() {
        try {
            i++;
            System.out.println("@@@@Count" + i);
            print();
        } catch (Exception e) {}
    }

    public void print() {
        try {
            StringBuilder bufData = new StringBuilder();
            File fileTest = new File("D:\\Work\\i466477");
            BufferedReader bufferedReader1 = new BufferedReader(new FileReader(
                    fileTest));
            String strRecord = new String();
            while ((strRecord = bufferedReader1.readLine()) != null) {
                bufData.append(strRecord);
                bufData.append("\r");
                bufData.append("\n");
            }
            bufferedReader1.close();
            System.out.println("########");
            System.out.println(bufData);

        } catch (Exception exe) {
            System.out.println(exe);
        }
    }
}
</code></pre>

<p>Here I could see the code in the <code>while</code> is by default synchronized, is <code>BufferedReader</code> thread safe or because each thread will have their own copy of <code>StringBuilder</code> and <code>BufferedReader</code>? I could see the contents are read and written properly.</p>
