c. Write a Java a program with a main thread and two user threads, thrdl and thrd2. i) Have thrdl use a Scanner to read integers from a String. There should be an even number of integers. ii) Thread thrd1 first reads two integers and then initializes to integer fields, x and y that are shared with thrd2. Thread thrd2 adds each new pair of integers and prints them out.
Q: IN C language Write a multithreaded program, that request the user to enter a string value, and…
A: In step 2, you will get the c code. In step 3, you can see the sample output. In step 4, you will…
Q: • Please simulate a Best Fit memory block allocation algorithm. • Your program runs without command…
A: Code :-
Q: c) Create a thread class named Worker that takes two positive integers, when it starts running, it…
A: ANSWER:-
Q: implement a bridge simulation using threads and semaphores. The bridge (the grey rectangle)should…
A: The bridge (the grey rectangle)should have 600kg capacity. Each person (you can draw them as…
Q: Convert this C++ program into C #include #include // size of array #define MAX 100 //…
A: Given is a c++ program and required is to convert the given code into a c program.
Q: For this assignment you need to write a parallel program in C++ using OpenMP for vector addition.…
A: Parallel programming : In processing, an parallel programming model is a deliberation of parallel PC…
Q: In C++ This exercise involves implementing the solution to the bounded buffer/readers and writers…
A: Explanation given in step 2
Q: In quicksort, after finishing the first partitioning, the array is looking like this: 25189 12 11 10
A: Step 1:- 8 and 9 are at their correct positionsAll elements on the left of 8 and 9 are smaller than…
Q: Write a multithreaded program using Pthreadlibraryin C++ that calculates various statistical…
A: Write a multithreaded program using Pthreadlibraryin C++ that calculates various statistical…
Q: 2. Implement the frame replacement algorithm for virtual memory In Java For this task, you need to…
A:
Q: Need Help with C++ coding, and please explain the first step in detail. Write a program in C++ that…
A: Answer: I have done code and also I have attached code and code screenshot as well as output
Q: 2. Write a program to perform the following operations on a stack: push(800), push(100), pop( ),…
A: Step 1: create global variable stack[] ,top = -1, n =100 Step 2 : Create push() function, for…
Q: using pthreads, which calculates the sum of elements in a hard-coded integer array in parallel using…
A: Actually, program is a executable software that runs a computer.
Q: what is the output of the code? Is the code have parallel programming ? Explain in depth about the…
A: Answer: Yes, the given code is parallel programming, this method is suitable for the problem.…
Q: Write a C programthat asks the user to enter the amount of pencils(inKilograms) that he wants to…
A: Given: Write a C programthat asks the user to enter the amount of pencils(inKilograms) that he wants…
Q: You are required to demonstrate the running time difference between a linked list and a binary…
A: Answer has been explained below:-
Q: Exercise 3: 1) Read the following code and try to guess what will be its output. import java.util.":…
A: 1) Code: import java.util.*;class Car{private int speed;//declaring private variablepublic void…
Q: 1- Write a program in MIPS assembly language to calculate the sum of a list of positive numbers. The…
A: 1. create function array sum a. loop through each value in array i. add to the…
Q: A Sudoku puzzle uses a 9 × 9 grid in which each column and row, as well as each of the nine 3 × 3…
A: The program is as follows:
Q: a list to store processes is used in this program, is it a queue or a general-purpose list?…
A: That program contain the process cycle , Burst Time , Waiting Time and Turnaround time so we can say…
Q: Write a program using multi-threads in which create a global integer vector.
A: The following C++ code has three functions each for three different datatypes.Code: #include…
Q: mplement a Multithreaded Sudoku Solution Validator using POSIX thread library in C Specifications…
A: Create a text file sudoku.txt and write the numbers in the format as follows: 6 2 4 5 3 9 1 8 7 5 1…
Q: Question Write a program in C which creates 10 POSIX threads. These threads must individually…
A: The code is written below In c language- #include <stdio.h> // including header file for io…
Q: Consider the movie ticket booking Application. The Application need to book the ticket with the…
A: Solution:-- 1)The given problem in the question is expected to provide the solution in the Java…
Q: Write a program in C which creates 10 POSIX threads. These threads must individually generate arrays…
A: The POSIX thread libraries are a thread API for C/C++ based on standards. It enables us to spawn a…
Q: using C language Write a program that creates an array of length 10, then creates 8 threads. should…
A: Write a program that creates an array of length 10, then creates 8 threads. should request entrance…
Q: 9.11 Can you write a swap routine in Java, or in any other language with only call- by-sharing…
A: Java does manipulate objects by reference, and all object variables are references. However, Java…
Q: please i just need screen shot for output
A: The code has the following error.
Q: Problem: A A class octopus has a dummy head which has four pointers left, right, top and bottom. You…
A: program code for the problem
Q: Consider an empty stack of integers and a text file with the following numbers: 1,2,3,4,5,6. You can…
A: Pop 3 Pop 2 Pop 5 Pop 6 Pop 4 Pop 1
Q: 2. Write a program Java to perform the following operations on a stack: push(800), push(100), pop(…
A: first time operation =push(800) again push(100). next pop() , it means 100 is removed from top.…
Q: ++ Write a program to store n integers in a chained hash table of 9 memory locations. Use h(k) = k…
A: The below code is to implement a chained hash table of 9 memory locations. The operations performed…
Q: Write a Java program to solve the following problem. You can make use of whichever of the ADTS Stack…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Write a C++ code with threads: Compute Tt by "randomly" choosing points. t is four times the…
A: It is defined as a general purpose programming language and widely used now a days for competitive…
Q: Using C++, Write a program to produce the first 100 Fibonacci numbers. A Fibonacci number is one…
A: Code to copy: #include <iostream>using namespace std;void print_Fibonacci_Numbers(int n){ int…
Q: Write a (C++) program in which 29 seperate linked lists (one for each Turkish alphabet letter) are…
A: Since the reference file is lacking, we proivide code to create multiple linked lists in C++
Q: = 2r*2r = 4
A: The c++ code is given as,
Q: Write a program that creates an array of length 10, then creates 8 threads. should request…
A: ANSWER: A Small Background of Producer-Consumer Problem: The Producer-Consumer Problem (sometimes…
Q: To solve the problem of mismatch between the speeds of computer and printer, we usually use a…
A: According to the information given:- We have to find out which data structure could used by buffer.
Q: Create an application in Java that creates n (this is set at the beginning of the application not…
A: Given that, Create an application in Java that creates n (this is set at the beginning of the…
Q: 1. Write a Java program which takes three arguments: first city name second city name third a path…
A: Step 1 : Start Step 2 : In the main method , Declare the string variables to store the passed…
Q: Write a program that creates a certain number of sellerthreads that attempt to sell all the…
A: The program as per the given requirements is provided in the next step:
Q: public static void main(String[] args) int a; int b; int c; c = quad(0,1, 2); b = quad(1, 2, 3); a =…
A: Activation record is used to manage the information needed by a single execution of a procedure. An…
Q: Write a C++ program to produce the first 90 Fibonacci numbers. A Fibonacci number is one that I is…
A: Note: - As per our guidelines we can only answer one question at a time. Please resubmit the other…
Q: Write a Java program that creates a new thread called PrintEven, that prints the Even numbers…
A: GIVEN: Create a java program that creates a new thread PrintEven to print the even numbers between 1…
Q: b. If the order of the stack input stream "30,60,56,44,98" What is the output if we execute the…
A:
Q: For this assignment you need to write a parallel program in C++ using OpenMP for vector addition.…
A: Solution:-- 1)The given question has required for the solution as the program in the C++ language…
Q: Write a program that opens a text file (name the textfile “problem4.txt”) and reads its contents…
A: PROGRAM: //Defining the header files #include <iostream> #include <fstream> //Defining…
Q: Create an application in Java that creates n (this is set at the beginning of the application not…
A: The java code is gien below:-
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- Create two Stacks S1 and S2 on two different arrays. Push and Pop operations on S1and S2 are to be handled by separate Threads T1 and T2. Create a class called myException to override the toString() method. Raise the exception when size of S1 and S2 becomes equal. Note: please write a proper java program for the above syntaxException in thread "main" java.lang.NumberFormatException: For input string: "x" for Java code public class Finder { //Write two recursive functions, both of which will parse any length string that consists of digits and numbers. Both functions //should be in the same class and have the following signatures. //use the if/else statement , Find the base case and -1 till you get to base case //recursive function that adds up the digits in the String publicstaticint sumIt(String s) { //if String length is less or equal to 1 retrun 1. if (s.length()<= 1){ return Integer.parseInt(s); }else{ //use Integer.praseInt(s) to convert string to Integer //returns the interger values //else if the CharAt(value in index at 0 = 1) is not equal to the last vaule in the string else {//return the numeric values of a char value + call the SumIt method with a substring = 1 return Character.getNumericValue(s.charAt(0) ) + sumIt(s.substring(1)); } } //write a recursion function that will find…Write code in C language. Create an integer array as input in C programming language. Create two threads. The first thread sums the even elements of the array, and the second thread sums the odd elements of the array. You can declare only one function outside the main function
- Create an application in Java that creates n (this is set at the beginning of the application not read) threads in java. The i-th thread will be named "TXAM-i". Each thread job is to insert its name 3 times into an existing ArrayList stored in the Values class given below. Create the thread class and modify the below Values class such that we ensure that the values inserted by each thread are consecutive in the array. For example, if n=3 after running each thread the array may look as: ТХАМ-2, ТХАМ-2, ТХАМ-2, ТХАМ-1, ТХАМ-1, ТХАМ-1, ТХАМ-3, ТХАМ-3, ТХАМ-3 But will never look like (values are mixed): ΤΧΑΜ-2, ΤΧAM-3, ΤΧΑΜ-1, ΤΧΑM-2, TΧΑM-3, TΧΑM-1, ΤΧAM-2, TΧΑM- 1, TXAM-3 private class Values { private ArrayList deposit; public Values () { deposit = new ArrayList(); } }10. Write a multi-threading JAVA program having four threads:- The “Generator” thread: it takes as argument (in the constructor) aninteger N and generates an array of N integers- The “Even” thread: it takes as argument (in the constructor) an array ofintegers and counts the number of even numbers in the array- The “Odd” thread: it takes as argument (in the constructor) an array ofintegers and count the number of odd numbers in the array- The main thread:o it asks the user to enter an integer No Then, it runs the “Generator” thread to create an array of integersand waits the end of “Generator”o Then, it run “Even” and “Odd” to count the number of even andodd numbers in the generated arrayo Finally, it prints if there is more even or odd numbersNote: the main thread should wait the end of “Even” and “Odd”threads before printing the final result.using C language Write a program that creates an array of length 10, then creates 8 threads. should request entrance to their critical sections that is controlled through semaphores, read the values written in the array, and write it to the screen with the following format: "Consumer number - consumed item number-with the value-" And to a file named "Consumer activity", then exit the critical section, and repeat till the producers stop production. The total number of elements generated by the producer and consumed by the consumers should be 10,000,000 number
- In this assignment, you are provided with working code that does the following: 1. You input a sentence (containing no more than 50 characters). 2. The program will read the sentence and put it into an array of characters. 3. Then, it creates one thread for each character in the sentence. 4. The goal of the program is to capitalize each letter that has an odd index. The given program actually does this, but lacks the synchronization of the threads, so the output is not correct. You will need to provide the synchronization using mutex locks. Specifically, you are to (1) declare the mutex lock, (2) initialize the mutex lock, (3) lock and unlock the mutex lock at an appropriate location that results in the code working as expected, and (4) destroy the mutex lock. Be sure to place the mutex locks so that your program works correctly every time. Do not remove code or functions – you are to add the synchronization pieces only. When compiling using the GNU C compiler, be sure to include the…Write a multithreaded program that will accept 4 strings from the command line and search in a particular file for a given string and display the status of each search on the screen. Note that, all threads are operating on the same file. write java codeAssume that we have a file named “sharable.txt" that can be shared among several threads. We want to write a program that controls the access to that file in a way that only one thread at a time is allowed to access that file (i.e., for writing/appending purposes). Using Java multithreading, write a program that creates three threads and assigns a number to each thread. Then, each thread will start running by executing a code for opening the file "sharable.txt" and writing the following lines: Thread x started writing Thread x is currently writing Thread x finished writing Your program should allow only one thread -at any given time-to access the file and write in it. It also should keep away any thread from overwriting the lines written by any other threads (hint: use synchronized method/blocks). Finally, when the execution of the program is completed, the output stored in “sharable.txt" should look like the following: Thread x started writing Thread x is currently writing Thread x…
- A Sudoku puzzle uses a 9 × 9 grid in which each column and row, as well as each of the nine 3 × 3 sub grids, must contain all the digits 1 ··· 9. Implement a multithreaded application in C using Pthreads that reads the solution from a text file and determines if the solution to a Sudoku puzzle is valid. Your solution must not use more than 11 threads. Use semaphores in your program to synchronize the threads.Develop a program that will do the following using Java and Javaclasses of Filewriter and Arraylist: The program has the interface[A] Add[D] Delete[U] Update[S] Search[X] Exit Select Operation: A You are about to add a user. Enter the First name:Enter the Last name:Enter the username:Enter password: The user has been successfully added. Do you wish to do another operation? [Y/N]: Y ---------------------------------------------------------------------------------------------- [A] Add[U] Update[S] Search[D] Delete[X] Exit Select Operation: U You are about to update user information. Search ID: 3 User information:First name: GeraldLast name: MorenoUsername: igeraldPassword: egerald Enter new username: asxsEnter new password: erdasdfr Username and Password have been updated successfully. Do you wish to do another operation? [Y/N]: Y ---------------------------------------------------------------------------------------------------------- [A] Add[U] Update[S] Search[D] Delete[X] Exit Select…3. Implement mutual exclusion with multithreading in Java Build a Java program which simulates a communication between a server and clients. You must use a thread to represent each party (as server or client). (Hint: study about the Semaphore class to perform mutual exclusion between threads) Create three threads. One thread will act as a server, which always ready to receive a message from a client (ping) and then replies the message to the same client (pong). The other two threads will become the clients, where each client will send a message to the server (ping) and waits for the reply (pong). Define 2 different classes to represent the server and the client. To perform the communication, each thread will refer to a same variable/data structure for sending and receiving the message. Use mutual exclusion approach to ensure each client can send and receive the reply without interruption from any other client(s). For this simulation, your objective is to ensure that each client must…