package HomeworkLib1;
import java.util.Random;
public class Thread1 extends Thread{
int array[];
Thread1(){ //Constructor that creates the object
array = new int[100000]; //and initializes the array with random nos
Random rand = new Random();
for(int i=0; i<100000; i++) {
array[i] = rand.nextInt(100000);
}
}
public void run() { //Sort the array in thread
System.out.println("Sorting in thread...");
sort(this.array);
}
public static void main(String[] args) throws Exception{
Thread1 t1 = new Thread1(); //Creating thread
System.out.println("First 100 elements unsorted :");
for(int i=0; i<100; i++) { //Displaying first 100 numbers from random array
System.out.print(t1.array[i] + " ");
if((i+1) %10 == 0)
System.out.println();
}
System.out.println();
t1.start(); //Starting the thread to sort the array
Thread.sleep(500); //Force the main thread to sleep so that
//thread sorting is completed
System.out.println("\nFirst 100 elements sorted :");
for(int i=0; i<100; i++) { //Printing 100 sorted elements.
System.out.print(t1.array[i] + " ");
if((i+1) %10 == 0)
System.out.println();
}
}
public static void sort(int arr[]) //Insertion sort
{
int n = arr.length;
for (int i = 1; i < n; ++i) {
int key = arr[i];
int j = i - 1;
/* Move elements of arr[0..i-1], that are
greater than key, to one position ahead
of their current position */
while (j >= 0 && arr[j] > key) {
arr[j + 1] = arr[j];
j = j - 1;
}
arr[j + 1] = key;
}
}
}

How to make a thread that sorts 100k random integers in java language Thread #1 -...
How to code a program in java language were 2 threads run Thread #1 - IntegerSorter class - sorts 100k random integers (values ranging from 0-100,000) Thread #2 - StringSorter class - sorts 30k element String array Driver.java, which includes “main” and invokes both threads
Please use java Language
Part I Implement a thread by extending the Thread class. Your thread must do the following: (25 pts.) • Print its name and ID at the start. • Print the numbers from 1 to 100 that can be divided by 5. • Wait 1 second before printing a number. Part II Implement a thread by implementing the Runnable interface. Your thread must do the following: (25 pts.) • Print its name and ID at the start....
java language question: Write a thread that tosses a coin 1000 times and computes the frequency of heads and tails. A coin can be modelled by a random number generator that generates random numbers in the range 0..1.
A. Create a java program that generates 1000 random integers. Write the 1000 random integers to a file using the Formatter class. B. Create a second java program that opens the file with the 1000 integers using the Scanner class. Read in the integers and find and print out the largest, smallest and the average of all 1000 numbers. C. Repeat A from above but use the BufferedWriter class B. Repeat B from above but use the BufferedReader class.
C language
Write a program that generates 20 random integers (ranging in between 0 to 100) and outputs all the even random numbers.
c# prograaming language
1. write a program that generates 10,000 random integers in the
range of 0-9 and them in binary search tree.
2. use any sort algorithm (insertion, bubble, quick...) to
display a list of each of the integers and how many times they
appear.
3. at last, add ruction to the BinarySearchTree class that count
the number of edges in a tree.
Write a program that generates 10,000 random integers in the range of 0-9 and store them...
write a program in x86 assembly language that sorts 10 integers entered from the keyboard and displays them in order
Language is Java. Create an insertion, selection, quick, and merge sort algorithm that sorts 6 9 8 12 3 1 7
Please write in java program Write an application that generates 100 random integers between 1 and 75 and writes them to a file named "file_activity.txt". Read the data back from the file and display the following: The sum of the numbers in the file The average of the numbers in the file The numbers in the file in increasing order To sort an array: int[] arr = new int[20]; Arrays.sort(arr); -- this sorts an array To sort an ArrayList: ArrayList<Integer>...
Please help me to solve this problem with java language!
write a program that runs a thread which prints a timestamp and then waits a second by doing the following: 1. Implement a class that implements the Runnable interface. (1 point) 2. Place the code for your task into the run method of your class. (6 points) a) To get the date and time, construct a Date object. b) To wait a second, use the sleep method of the Thread...