Created
July 21, 2015 05:45
-
-
Save hrchu/24346a226953b1c378a6 to your computer and use it in GitHub Desktop.
Test Moji concurrency behavior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fm.last.moji.MojiFile; | |
/** | |
* Created by developer on 4/30/15. | |
*/ | |
class MogileOperator implements Runnable { | |
@Override | |
public void run() { | |
MojiFile rickRoll = TestMojiConcurrency.moji.getFile("rick-astley"); | |
while(true) { | |
try { | |
rickRoll.exists(); | |
System.out.println(Thread.currentThread().getId()); | |
Thread.sleep(0); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
System.exit(-1); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fm.last.moji.spring.SpringMojiBean; | |
/** | |
* Created by developer on 4/30/15. | |
*/ | |
public class TestMojiConcurrency { | |
static SpringMojiBean moji; | |
public static void main(String[] args) { | |
moji = new SpringMojiBean("tracker01:7001, 10.144.129.203:7001", "dom1"); | |
moji.setTestOnBorrow(true); | |
int count = 1; | |
if (args.length !=0) { | |
count = Integer.parseInt(args[0]); | |
} | |
for (int i=0; i < count; i++) { | |
Thread t = new Thread(new MogileOperator()); | |
t.start(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment