68 774
Assignments Done
Successfully Done
In January 2019

Answer to Question #66998 in Java | JSP | JSF for Gene Moore

Question #66998
Provide a programming example in which multithreading does not provide better performance than a single-threaded solution
Expert's answer
Example below shows, that multi-threading programs not always have performance benefit.

For example simple tasks(like iterating 100 elements) will not give better performance, but will use more CPU and RAM memory for it


import java.util.Random;

public class Main {

public static void main(String[] args) {
int[] arr = new int[100];

new Thread(() -> {

for (int i = 0; i < arr.length; i++) {
arr[i] = new Random().nextInt();
System.out.println("Thread " + arr[i]);

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions