Advertisement

11.01.2008 at 09:16PM PDT, ID: 23868342
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.5

How do I create 2 runnables each with 4 threads

Asked by sexy10 in Java Editors & IDEs, New to Java Programming

Tags:

Im not sure how to implement 2 Runnables using the run() method in the first Runnable to print "Runnable 1" and print the thread's name, id, and priority. The second Runnable needs to print "Runnable 2" and print the thread's name, id, and priority.  Runnable 1 will show thread 1 thru 4 and runnable 2 will show threads 5 thru 8.
this is what I have so far,
public class ThreadCreation {
   
public static void main(String[] args)
  {
 
    // create the counters
    Thread thread1 = new Thread (new Print("thread1"));
    Thread thread2 = new Thread (new Print("thread2"));
    Thread thread3 = new Thread (new Print("thread3"));
    Thread thread4 = new Thread (new Print("thread4"));

      // set their priorities
        thread1.setPriority(Thread.MAX_PRIORITY);
        thread2.setPriority(Thread.NORM_PRIORITY);
      thread3.setPriority(Thread.MIN_PRIORITY);
        thread4.setPriority(Thread.MAX_PRIORITY);
         

      // run them in any old order -
    thread1.start();
    thread2.start();
    thread3.start();
    thread4.start();
   
 System.out.println(Thread.currentThread());
  }
}

import java.lang.Object;


public class Print implements Runnable
{
    private String thread_name;
   
      public Print (String name)
  {                             // set thread name
       thread_name = name;
         
  } //end constructor
         
  public void run() //output thread name, thread id and thread priority
  {
     
      System.out.printf(thread_name + " " + Thread.currentThread().getId()
                + " " + Thread.currentThread().getPriority() + "\n");
  }
}


Start Free Trial
 
Loading Advertisement...
 
[+][-]11.01.2008 at 09:47PM PDT, ID: 22860240

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]11.01.2008 at 09:52PM PDT, ID: 22860246

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.01.2008 at 10:07PM PDT, ID: 22860272

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Java Editors & IDEs, New to Java Programming
Tags: Java
Sign Up Now!
Solution Provided By: mwvisa1
Participating Experts: 1
Solution Grade: A
 
 
[+][-]11.01.2008 at 10:51PM PDT, ID: 22860367

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]11.01.2008 at 10:52PM PDT, ID: 22860371

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]11.03.2008 at 03:13AM PST, ID: 22866026

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.03.2008 at 03:15AM PST, ID: 22866039

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.03.2008 at 05:07AM PST, ID: 22866679

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]11.04.2008 at 07:13PM PST, ID: 22882916

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.04.2008 at 07:24PM PST, ID: 22882949

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]11.04.2008 at 08:18PM PST, ID: 22883104

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.04.2008 at 08:27PM PST, ID: 22883132

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.04.2008 at 08:35PM PST, ID: 22883165

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]11.04.2008 at 08:56PM PST, ID: 22883231

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.05.2008 at 05:11AM PST, ID: 22885209

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]11.05.2008 at 06:51PM PST, ID: 22892059

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.05.2008 at 07:47PM PST, ID: 22892247

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]11.06.2008 at 10:55PM PST, ID: 22902327

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.07.2008 at 04:02AM PST, ID: 22903557

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628