@@ -0,0 +1,698 @@
+package threads;%0A%0Aclass FooBar %7B%0A    private int n;%0A%0A    public FooBar(int n) %7B%0A        this.n = n;%0A    %7D%0A%0A    public void foo() %7B%0A        for (int i = 0; i %3C n; i++) %7B%0A            System.out.println(%22foo%22);%0A        %7D%0A    %7D%0A%0A    public void bar() %7B%0A        for (int i = 0; i %3C n; i++) %7B%0A            System.out.println(%22bar%22);%0A        %7D%0A    %7D%0A%7D%0A%0Apublic class PrintFooBarAlternatively %7B%0A    public static void main(String%5B%5D args) %7B%0A        int count = 3;%0A        FooBar target = new FooBar(count);%0A%0A        Thread a = new Thread(() -%3E %7B%0A            target.foo();%0A        %7D);%0A%0A        Thread b = new Thread(() -%3E %7B%0A            target.bar();%0A%0A        %7D);%0A%0A        b.start();%0A        a.start();%0A    %7D%0A%7D%0A

print "foo" "bar" alternatively with given count