Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9152959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:10:48+00:00 2026-06-17T12:10:48+00:00

Create a Student class with name, mark1, mark2, mark3 and sum variables. Create an

  • 0
  1. Create a Student class with name, mark1, mark2, mark3 and sum variables.
  2. Create an ArrayList with 4 student objects with some values.
  3. Create a MarkEvaluation thread and ShowMark thread.
  4. MarkEvaluation should perform the calculation of the total marks for each student.
  5. ShowMark thread should display the calculated sum.
  6. Use the join method to prevent the ShowMark thread to run before MarkEvaluation.

Its not homework.Part of some practice am doing.Here they asked me to run 2 threads doing different things but I don’t know if we can run 2 run() methods.How can I perform 2 different operations? Sorry am just starting to learn threads.This is what I’ve done but it is incomplete.

import java.util.*;

class Student implements Runnable
 {
 public Student()
 {
     List<Object> list = new ArrayList<Object>();
     list.add("robin");
     list.add("ravi");
     list.add("raj");
     list.add("sam");
 }
 String name;
 int mark1=30,mark2=45,mark3=70,sum=0;

 public void run()
  {
    sum = mark1+mark2+mark3;
  }

}

public class Ch3Lu2Ex3
 {
  public static void main(String[] args) 
  {
    Student stu = new Student();
    Thread MarkEvaluation = new Thread(stu);
    MarkEvaluation.start();
    Thread ShowMark = new Thread();

}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:10:49+00:00Added an answer on June 17, 2026 at 12:10 pm

    You’re on the right track. What you want to do now is create another Runnable class for displaying the resulting sum, and you need to find some way of sharing the calculated sum from the MarkEvaluation thread. I suggest using a BlockingQueue, as the take() method will block until the sum has been put onto the thread, satisfying your last requirement without having to use join().

    Explicitly, you need 2 classes implementing Runnable, 1 you already have, and another for displaying the result. You need to share a BlockingQueue between them, and you need to start both threads by instantiating a Thread and calling start(). Hopefully this will put you on the right track without simply giving you the code.

    Alternatively, you could have the ShowMark Runnable keep a reference to Student as well as the thread used to run Student (called MarkEvaluation above), join on the thread, and then call getSum() (or similar) to retrieve the sum from Student.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a model with some classes: class Student(models.Model): name = models.CharField(max_length=40) last_name
I have an object Student with 4 attributes(age,name,department,surname). and I create an array of
My two classes are designed too create an array of StudentData objects (name, Date
Possible Duplicate: Sorting an ArrayList of Contacts based on name? I have a student
I have class Student , I want to create multiple instance of class Student
I have created a program for my ASP.NET class to create a class name
Let's have this code : class student :IComparable , IComparable<student> { public string name
I wanted to make a class GradeBook, then create an object for each student,
I have a table which consists of the following Student Name Grade Class --------------------------------------------------------
I have a student class and every student instance created needs to be stored

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.