Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating two different threads
    primarykey
    data
    text
    <p>I'm new to threads and I have a question. </p> <p>I need to create two different threads.</p> <p>In the first thread, I need to read a file and copy it into another file. </p> <p>In the second thread, I need to put numbers in ascending order.</p> <p>I have my code for the first thread info:</p> <pre><code>package java10; import java.io.File; import java.io.IOException; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileNotFoundException; class FileCopy { public static void main(String[] args) { try { File fileIn = new File("C:/Users/dis_YO_boi/Documents/Abhishek.txt"); File fileOut = new File("C:/Users/dis_YO_boi/Documents/Mallela.txt"); FileInputStream streamIn = new FileInputStream(fileIn); FileOutputStream streamOut = new FileOutputStream(fileOut); int c; while ((c = streamIn.read()) != -1) { streamOut.write(c); } streamIn.close(); streamOut.close(); } catch (FileNotFoundException e) { System.out.println("FileCopy: " + e); } catch (IOException e) { System.out.println("FileCopy: " + e); } } } </code></pre> <p>I have my code for the second thread info:</p> <pre><code>package java10; public class Ascending { public static void main(String[] args) { int nums[]={-1,23,50,-100,34}; //print the values before ordering for (int i=0;i&lt;nums.length;i++) System.out.println(nums[i]); for(int i=0;i&lt;nums.length-1;i++){ for(int j=i+1;j&lt;nums.length;j++){ if(nums[i]&gt;nums[j]){ int temp=nums[i]; nums[i]=nums[j]; nums[j]=temp; } } } System.out.println("___________________________"); for (int i=0;i&lt;nums.length;i++) System.out.println(nums[i]); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload