Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG ?] Global Queue look weird? #4

Open
Larandar opened this issue Jun 29, 2012 · 0 comments
Open

[BUG ?] Global Queue look weird? #4

Larandar opened this issue Jun 29, 2012 · 0 comments

Comments

@Larandar
Copy link

First of all this is the TestClass where bug come :

import org.fusesource.hawtdispatch.*;
public class TestClass {

    public static class HawtDispatchTest implements Runnable {
        public String string ;
        public HawtDispatchTest( String string ) {
            this.string = string;
        }

        public void run() {
            System.out.println( this.string );
        } 
    }

    public static void main(String[] args) {
        // Use 1 threads
        System.setProperty("hawtdispatch.threads", "1" );

        for ( int i = 0 ; i < 10000 ; i++ ) {
            for ( DispatchPriority priority : DispatchPriority.values()) {
                Dispatch.getGlobalQueue(priority).execute(new HawtDispatchTest(priority.toString() + " : " + i));
            }
        }
    }
}

So now the weird thing , the log :

HIGH : 0
DEFAULT : 0
LOW : 0
HIGH : 1
DEFAULT : 1
...........
HIGH : 44
DEFAULT : 44
LOW : 44
HIGH : 45
DEFAULT : 45
LOW : 45
LOW : 46
LOW : 47
LOW : 48
LOW : 49
LOW : 50
LOW : 51
...........
LOW : 522
LOW : 523
LOW : 524
LOW : 525
LOW : 526
LOW : 527
LOW : 528
HIGH : 46
HIGH : 47
HIGH : 48
HIGH : 49
HIGH : 50
HIGH : 51
HIGH : 52
HIGH : 53
HIGH : 54
HIGH : 55
HIGH : 56
HIGH : 57
HIGH : 58
HIGH : 59
HIGH : 60
HIGH : 61
HIGH : 62
HIGH : 63
HIGH : 64
HIGH : 65
HIGH : 66
HIGH : 67
HIGH : 68
...........
HIGH : 235
HIGH : 236
HIGH : 237
HIGH : 238
HIGH : 239
HIGH : 240
HIGH : 241
LOW : 529
LOW : 530
DEFAULT : 46
DEFAULT : 47
DEFAULT : 48
DEFAULT : 49
DEFAULT : 50
DEFAULT : 51
DEFAULT : 52
DEFAULT : 53
DEFAULT : 54
DEFAULT : 55
...........
DEFAULT : 618
DEFAULT : 619
DEFAULT : 620
DEFAULT : 621
DEFAULT : 622
DEFAULT : 623

First thread is in sync, then when not sync GlobalQueue execute LOW priority then HIGHT then DEFAULT.
Does my using method not good ? I will prefer the global queue to do HIGHT then DEFAULT then LOW, there is a way to do it ?
Thank

PS: Task after 630 was not execute.
PPS : Was running in ANT to slow down, in java -jar result are more weird on my computer by changing tendance several time, but go to 2500 in test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant