Results 1 to 3 of 3
  1. #1
    scarymovie is offline Member
    Join Date
    Mar 2009
    Posts
    12
    Rep Power
    0

    Default Concurrency system, and threads.

    I have a project that requires me to write a concurrency system with java (of coz,this is a java forum). 1 main program and 2 thread classes are required. I have only this for reference:

    public static void travel (int distance, int id)
    {
    int multiplier = 100;
    timer(distance*multiplier*id);
    }

    public static void stop (int time)
    {
    timer(time);
    }

    private static void timer (int time)
    {
    int speedFactor = 10000;
    {
    for (int j = 0; j < time; j++)
    for (int k = 0; k < speedFactor; k++)
    {
    double r = k/2 * 2;
    }

    }
    }

    Well, with this, I ain't go anywhere. I planned to have a timer which actually simulates the time taken. Hope to get some advice here. Thanks.

  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    "You guys start coding while I go ask the user what he wants."
    Anonymous

    Writing a program with two threads is not a design. Figure out what you want your program to do first. That only requires the infamous "paper and pencil" I frequently mention. Once you have a design, then you can figure out how to make it work. If your design doesn't need two threads, then start over and make your problem harder.

  3. #3
    scarymovie is offline Member
    Join Date
    Mar 2009
    Posts
    12
    Rep Power
    0

    Default

    Quote Originally Posted by Steve11235 View Post
    "You guys start coding while I go ask the user what he wants."
    Anonymous

    Writing a program with two threads is not a design. Figure out what you want your program to do first. That only requires the infamous "paper and pencil" I frequently mention. Once you have a design, then you can figure out how to make it work. If your design doesn't need two threads, then start over and make your problem harder.
    Hey Steve, I do have what I want it to do (a list), just that I can't figure out how to implement.

Similar Threads

  1. concurrency question
    By diggitydoggz in forum New To Java
    Replies: 4
    Last Post: 01-17-2009, 04:48 AM
  2. Threads!
    By rameshraj in forum Advanced Java
    Replies: 1
    Last Post: 05-04-2008, 05:11 PM
  3. Using threads
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-11-2007, 11:25 AM
  4. Threads
    By one198 in forum Threads and Synchronization
    Replies: 1
    Last Post: 11-20-2007, 07:15 PM
  5. Explanation bout threading and concurrency?
    By cruxblack in forum New To Java
    Replies: 1
    Last Post: 08-10-2007, 11:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •