Search:

Type: Posts; User: Slapy

Search: Search took 0.07 seconds.

  1. Replies
    10
    Views
    1,765

    [SOLVED] Re: Am I doing it right?

    I think it should execute 3 threads:


    for (int i = 0; i < 3; i++)
    pool.execute(new Counter(i));

    or am I wrong?

    --- Update ---
  2. Replies
    10
    Views
    1,765

    [SOLVED] Re: Am I doing it right?

    oh am so sorry. I messed it up. It should be just 3 threads not 4 and it is just luck which thread will be selected. For example this is one of my outputs.
  3. Replies
    10
    Views
    1,765

    [SOLVED] Re: Am I doing it right?

    It is just simpl program that have to count form 0 to 50 and to do so have to use 3 threads and output have to be:

    Thread 1: 0
    Thread 0: 1
    Thread 2: 2
    Thread 2: 3
    Thread 1: 4
    ...
    Thread 0: 50
  4. Replies
    10
    Views
    1,765

    [SOLVED] Re: Am I doing it right?

    Yes, I was just asking if there is any way how to do it better.
  5. Replies
    10
    Views
    1,765

    [SOLVED] Re: Am I doing it right?

    So here is it after few changes I made:


    import java.util.concurrent.ExecutorService;
    import java.util.concurrent.Executors;
    import java.util.concurrent.atomic.AtomicInteger;

    public class...
  6. Replies
    10
    Views
    1,765

    [SOLVED] Am I doing it right?

    This are my two classes:


    import java.util.concurrent.ExecutorService;
    import java.util.concurrent.Executors;

    public class Main {

    public static int number = 0;
Results 1 to 6 of 6