Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Assume that you are trying to download a large 2-GB file from the Internet.
The file is available from a set of mirror servers, each of which can deliver a
subset of the file’s bytes; assume that a given request specifies the starting
and ending bytes of the file. Explain how you might use threads to improve
the download time. Also implement same.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- JAVA PROGRAMMING You are required to create a main class to apply ExecuterService with SingleThreadExecuter. The variable i is integer number and MUST be input from the keyboard. Output should be like this: Please input i: 3 pool-1-thread-1: 1 pool-3-thread-1: 1 pool-3-thread-1: 2 pool-3-thread-1: 3 pool-2-thread-1: 1 pool-2-thread-1: 2 pool-2-thread-1: 3 pool-1-thread-1: 2 pool-1-thread-1: 3 Total = 9Below is the part of code.class Counter public class Counter { private int counter; public void increment(){ counter++; } public void decrement(){ counter--; } synchronized public void myIncrement(){ counter++; } synchronized public void myDecrement(){ counter--; } }arrow_forwardWrite a Java program using Thread with single Server and Multiple Clients. NOTE: Client must be running until Bye message is sent. Server should never stop. I need answer question plsarrow_forwardcan you do this in Java, please? Thank youarrow_forward
- Write a multithreaded Hello World program using OpenMP. Have each thread say “Hello world” along with its thread ID and the number of threads the program is using.Run the program with as many threads as your computer will allow. Then try setting the thread count to a different number. please post:- The source code.- A screenshot of the program running.- A screenshot of the program running with a different thread count.arrow_forwardYou'll write a C++ program to demonstrate thread synchronization. Your main function should first create an empty file called *sync.txt*. Then it will create two separate threads: *Thread-A* and *Thread-B*. Both threads will open *sync.txt* and write to it simultaneously. *Thread-A* will write the numbers 0 through 9, a total of fifty-thousand times in nested `for` loops, then exit. In other words, print the numbers 0 through 9 over and over again, with each run on a separate line, for 50,000 lines. Here's an example of one such line: ```text 0 1 2 3 4 5 6 7 8 9 ``` Somewhat similarly, *Thread-B* will write the letters A through Z fifty-thousand times in nested `for` loops, then exit. In other words, print the letters A through Z over and over again, with each run on a separate line, for 50,000 lines. Here's an example of one such line: ```text A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ``` Do not write each line as one long string. You must write each character to the…arrow_forwardTry pthreads.cpp. Modify it so that they run 3 threads (instead of two) and each thread runs a different function, displaying a different message. Copy-and-paste the source code and the outputs in your report. /* pthreads_demo.cpp A very simple example demonstrating the usage of pthreads. Compile: g++ -o pthreads_demo pthreads_demo.cpp -lpthread Execute: ./pthreads_demo */ #include <pthread.h> #include <stdio.h> using namespace std; //The thread void * thread_func (void *data) { char *tname = (char *) data; printf("My thread identifier is %s\n", tname); pthread_exit (0); } int main () { pthread_t id1, id2; //thread identifiers pthread_attr_t attr1, attr2; //set of thread attributes char *tnames[2] = { "Thread 1", "Thread 2" }; //names of threads //get the default attributes pthread_attr_init (&attr1); pthread_attr_init (&attr2); //create the threads pthread_create (&id1, &attr1, thread_func,…arrow_forward
- Modify this threading example to use, exclusively, multiprocessing, instead of threading. import threadingimport time class BankAccount(): def __init__(self, name, balance): self.name = name self.balance = balance def __str__(self): return self.name # These accounts are our shared resourcesaccount1 = BankAccount("account1", 100)account2 = BankAccount("account2", 0) class BankTransferThread(threading.Thread): def __init__(self, sender, receiver, amount): threading.Thread.__init__(self) self.sender = sender self.receiver = receiver self.amount = amount def run(self): sender_initial_balance = self.sender.balance sender_initial_balance -= self.amount # Inserting delay to allow switch between threads time.sleep(0.001) self.sender.balance = sender_initial_balance receiver_initial_balance = self.receiver.balance receiver_initial_balance += self.amount # Inserting delay to allow switch between threads time.sleep(0.001)…arrow_forwardExercise 1: Write a thread class TabPrinter that prints the elements of an array of integers (in one line) every 2 seconds 5 times. Use the way of extending the class thread. Write the main method which creates and starts three threads Printer which will print different arrays of integers. After that it prints "Main won’t wait. Main exits". Modify the above thread program so that you implement the interface Runnable. Make the main thread waiting till all other threads finish execution. ____________________________________________________________________________________________ Exercise 2: Write a thread class TextThread that prints a text every 1 second 10 times. Read the following main class. Try to guess what will be its output. class Test { public static void main(String s[]) throws Exception { TextThread x = new TextThread ("I am thread x"); TextThread y= new TextThread ("I am thread y"); System.out.println("I am Main thread"); } } Write it and execute it. Is the…arrow_forwardCould you kindly utilize solely my code as I contributed to its development? I emphasize, please utilize only my code.I attached my code below label my code. The question that I need help with: You need to use the pthread for matrix multiplication. Each threadfrom the threadpool should be responsible for computing only a partof the multiplication (partial product as shown in the above picture –all Ti(S) are called a partical product). Your main thread should splitthe matrices accordingly and create the partial data arrays that areneeded to compute each Ti. You must create a unique task with thedata and submit it to the job queue. You can compute the partialproducts concurrently as long as you have threads available in thethreadpool. You have to remove the task the from queue and submitto a thread in the threadpool. You should define the number ofthreads to be 5 and keep it dynamic so that we can test the samecode with a higher or lower number of threads as needed. When allthe…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education