Mercurial > hg > Members > shoshi > TreeCMSv1
diff src/treecms/proto/test/SimpleEditorTest2.java @ 30:8d733b98c5de
added Node API
setLinkedNode,getLinkedNode for create link to other node.
but not implemented yet.
author | Shoshi TAMAKI |
---|---|
date | Wed, 10 Nov 2010 00:36:51 +0900 |
parents | 64359341c04a |
children |
line wrap: on
line diff
--- a/src/treecms/proto/test/SimpleEditorTest2.java Tue Nov 09 18:13:54 2010 +0900 +++ b/src/treecms/proto/test/SimpleEditorTest2.java Wed Nov 10 00:36:51 2010 +0900 @@ -1,5 +1,12 @@ package treecms.proto.test; +/** + * SimpleEditorTest2 + * + * testMultiThread + * test concurrent monotonic-tree modification + */ + import java.util.LinkedList; import java.util.List; import java.util.Random; @@ -50,7 +57,7 @@ @Test public void testMultiThread() { - int threads = 10; + int threads = 10; //number of threads. final int modifyCount = 100; ExecutorService service = Executors.newFixedThreadPool(threads); @@ -60,18 +67,26 @@ @Override public void run() { - // TODO Auto-generated method stub SimpleEditor editor = new SimpleEditor(m_contents); Random random = new Random(); for(int i = 0;i < modifyCount;i ++){ List<Node> nodeList = transform(new PreOrderTreeWalker(m_contents.get())); + + //get random target from nodelist Node target = nodeList.get(Math.abs(random.nextInt(nodeList.size()))); + + //edit target editor.edit(target); - editor.commit(false); + + //force commit. + editor.commit(true); } } + /* + * convert iterator to list + */ public List<Node> transform(PreOrderTreeWalker _walker) { LinkedList<Node> nodeList = new LinkedList<Node>();