My Homework Help logo
  • Our services
    • Math homework Help
    • Excel Homework Help
    • Case Study Assignment Help | Do My Case Study Homework
    • PowerPoint Presentation Help
    • CIPD Assignment Help
    • Civil Engineering Homework Help – Do My Asssignment For Me
    • CPM Homework Help | Do My CPM Assignment For Me
    • Discussion Board Homework Help
    • Finance Homework Help – Do My Finance Assignment For Me
    • Nursing Homework Help
    • Programming Homework Help
    • SPSS Homework Help | Do My SPSS Assignment For Me Cheap
    • Statistics Homework Help
  • About Us
  • How It Works
  • My account
  • Order now
Order Now
Homework Help

Programming | Computer Science homework help

3 min read
Posted on 
February 21st, 2024
Home Homework Help Programming | Computer Science homework help

Threads in Java

Write a Java program that creates several threads, according to the following scenario:

 The initial thread will be called the main thread (M)

 The main thread (M) creates and starts two worker threads; each worker thread will work on its task

 The main thread (M) joins the two worker threads in the end and computes the final result

The goal of this program is to find all the Vampire numbers in the interval [100000, 999999]. To achieve this

goal we will scan all the integer numbers from 100000 to 999999 and for each of these numbers we must

perform a test to verify if that number is a Vampire number or not. In order to solve this problem faster,

(assuming we have at least two processors on our system) we will divide the work between the two worker

threads: on worker will scan and verify all the even numbers and the other worker will scan and verify all the

odd numbers in the interval.

More precisely, the following list describes the behavior of each thread:

1. The main thread (M) creates the two worker threads, starts them and joins them in the end. After that,

the main thread will compute and display the TOTAL number of Vampire numbers found in the interval

[100000, 999999] as “The TOTAL number of Vampire numbers found is: …” (the ellipsis stand for the

actual number)

2. The first worker will scan and verify all the even numbers in the interval [100000, 999999]; whenever a

new Vampire number is found, it will be displayed like this: “First worker found: …” (the ellipsis stand

for the actual number); a counter will be incremented every time a new Vampire number was found,

and in the end the total number of Vampire numbers found will be displayed: “First worker found …

Vampire numbers” (the ellipsis stand for the actual number)

3. The second worker will scan and verify all the odd numbers in the interval [100000, 999999]; whenever

a new Vampire number is found, it will be displayed like this: “Second worker found: …” (the ellipsis

stand for the actual number); a counter will be incremented every time a new Vampire number was

found, and in the end the total number of Vampire numbers found will be displayed: “Second worker

found … Vampire numbers” (the ellipsis stand for the actual number)

HINTS:

– The Vampire numbers are described in detail here: https://en.wikipedia.org/wiki/Vampire_number

– In the end, the worker threads must communicate their counters to the main thread, in order to

compute and display the TOTAL number of Vampire numbers in the interval

– Work on your computer or online using https://replit.com

DELIVERABLES:

– The source code for the Java program, stored in the text file “hw3.java”

– A screenshot showing the final results of your program’s execution, stored in a graphic file like

“hw3.png” or ”hw3.gif” or “hw3.pdf”, etc.

 

https://en.wikipedia.org/wiki/Vampire_number
https://replit.com/

Order an Essay Now & Get These Homework Help Features For Free:

Turnitin Report

Formatting

Title Page

Citation

Outline

Place an Order
Share
Tweet
Share
Tweet
Calculate the price
Pages (275 words)
$0.00
My Homework Help
Company
  • Get Homework Help
  • Home
  • About Us
  • How It Works
Legal
  • About
  • How It Works
How Our Homework Help and Essay Service:
My Homework Help The essays written at My Homework Help are not intended to be forwarded as finalized work, but they can still serve a dual purpose of research and study. My Homework Help does not endorse or encourage any form of plagiarism.
Subscribe
No Spam
  • Math homework Help
  • Excel Homework Help
  • Case Study Assignment Help | Do My Case Study Homework
  • PowerPoint Presentation Help
  • CIPD Assignment Help
  • Civil Engineering Homework Help – Do My Asssignment For Me
  • CPM Homework Help | Do My CPM Assignment For Me
  • Discussion Board Homework Help
  • Finance Homework Help – Do My Finance Assignment For Me
  • Nursing Homework Help
  • Programming Homework Help
  • SPSS Homework Help | Do My SPSS Assignment For Me Cheap
  • Statistics Homework Help
© 2025 My Homework Help. All rights reserved.
My Homework Help will be listed as ‘My Homework Help’ on your bank statement.

WhatsApp us