Permalink
Browse files

modified fine grained locking

  • Loading branch information...
1 parent 1200faf commit 89df5dfb6cbf0b23bde926ec620c32da77916cd8 @rowoot rowoot committed Sep 19, 2012
View
50 src/edu/buffalo/cse605/finelist/src/fineCursor.java
@@ -1,50 +0,0 @@
-package edu.buffalo.cse605.finelist.src;
-
-
-
-public class fineCursor<T> {
- private fineElement<T> curr;
- private fineWriter<T> writer = new fineWriter<T>(this);
-
- public fineCursor(fineElement<T> start) {
- this.curr = start;
-
- // Find out: Does it reference or assign ?
- }
-
- // TODO: needs to be not exposed to public
- public fineElement<T> curr(fineElement<T> curr) {
- this.curr = curr;
- return curr;
- }
-
-
- public fineElement<T> curr() {
- return this.curr;
- }
-
-
- public void next() {
- this.curr = curr.next();
- }
-
-
-
- public fineElement getnext(){
- return this.curr.next();
- }
-
- public fineElement getprev(){
- return this.curr().prev();
- }
-
- public void prev() {
- this.curr = curr.prev();
- }
-
-
- public fineWriter<T> fwriter() {
- return writer;
- }
-
-}
View
123 src/edu/buffalo/cse605/finelist/src/fineElement.java
@@ -1,123 +0,0 @@
-package edu.buffalo.cse605.finelist.src;
-
-import java.util.concurrent.locks.*;
-
-
-public class fineElement<T> {
- private T val;
- private fineElement<T> next, prev;
- public final Lock nextlock=new ReentrantLock();
- public final Lock prevlock=new ReentrantLock();
-
-
- // Constructor
- public fineElement(T val) {
- this(val, null, null);
- }
-
- // Constructor
- public fineElement(T val, fineElement<T> prev, fineElement<T> next) {
- if ( val == null ) {
- // Throw Exception
- throw new Error("can`t create element");
- }
- // Assign Value
- this.val = val;
- // Assign Prev and Next
- if ( prev != null && next != null ) {
- this.prev = prev;
- this.next = next;
- } else if ( prev == null && next == null ) {
- this.prev = this;
- this.next = this;
- }
-
- }
-
- // GET next Element
- public fineElement<T> next() {
- return this.next;
- }
-
- // GET prev Element
- public fineElement<T> prev() {
- return this.prev;
- }
-
- // Add an element after this element
- public boolean addAfter(fineElement<T> el) {
-
- el.next=this.next;
- el.prev=this;
- if(this.prev.prev==this){//having two elements
- this.prev.prev=el;
- this.next=el;
- }
- else if(this.prev==this){//having one elements
- this.prev=el;
- this.next=el;
-
- }
- else{
- this.next.prev=el;
- this.next=el;
- }
-
- //this.next = el;
- //el.prev = this;
- return true;
- }
-
- // Add an element before this element
- public boolean addBefore(fineElement<T> el) {
- el.next = this;
- el.prev=this.prev;
- if(this.next==this){
- this.prev=el;
- this.next=el;
- }
- else if(this.next.next==this){
- this.next.next=el;
- this.prev=el;
- }
- else{
- this.prev.next=el;
- this.prev=el;
- }
-
-
- return true;
- }
-
- public boolean delete(){
- System.out.println("delete "+this.val);
- if(this.next==this.prev && this.next!=this){//two elements in the list
- this.next.next=this.prev;
- this.next.prev=this.prev;
-
- }
- else if(this.prev==this.next.next){//three elements in the list
- this.next.prev=this.prev;
- this.prev.next=this.next;
-
- }
-
- else{this.next.prev=this.prev;
- this.prev.next=this.next;
-
- }
-
-
- return true;
- }
-
- // Helper
- public String toString() {
- return "v:" + this.val + ",prev:" + this.prev.val + ",next:" + this.next.val;
- }
-
- //@Override
- public T value() {
- return this.val;
- }
-}
View
27 src/edu/buffalo/cse605/finelist/src/fineFDList.java
@@ -1,27 +0,0 @@
-package edu.buffalo.cse605.finelist.src;
-
-
-public class fineFDList<T> {
- private fineElement<T> head;
- private fineCursor<T> cursor;
-
-
-
- public fineFDList(T val) {
- this.head = new fineElement<T>(val, null, null);
-
- }
-
-
- public fineElement<T> head() {
- return this.head;
- }
-
- public fineCursor<T> freader(fineElement<T> start) {
- if (cursor == null) {
- cursor = new fineCursor<T>(start);
- }
- // TODO: Logical Fallacy, make sure I can call reader multiple times
- return this.cursor;
- }
-}
View
22 src/edu/buffalo/cse605/finelist/src/fineMain.java
@@ -1,22 +0,0 @@
-package edu.buffalo.cse605.finelist.src;
-
-import java.io.IOException;
-
-
-public class fineMain {
-
-
- public static void main(String[] args){
- fineFDList<String> f;
- f = new fineFDList<String> ("hi");
- testThread test1=new testThread(f);
- testThread2 test2=new testThread2(f);
- testThread2 test3=new testThread2(f);
- test1.start();
-
- test2.start();
- test3.start();
-
-
- }
-}
View
149 src/edu/buffalo/cse605/finelist/src/fineWriter.java
@@ -1,149 +0,0 @@
-package edu.buffalo.cse605.finelist.src;
-
-public class fineWriter<T> {
- private fineCursor<T> cursor;
-
- public fineWriter(fineCursor<T> cursor) {
- this.cursor=cursor;
- }
-
-
- public boolean insertBefore(T val) {
- //System.out.println("insert before");
- System.out.println("insertbefore "+val+" "+Thread.currentThread().getId());
- fineElement<T> e = new fineElement<T>(val);
- boolean prevl=false;
- boolean nextl=false;
- boolean unchanged=true;
- fineElement<T> t1=cursor.curr();
- fineElement<T> t2=cursor.curr();
- try {
- while((!(prevl&&nextl))&&unchanged){
- if(prevl){cursor.curr().prev().nextlock.unlock();}
- if(nextl){cursor.curr().prevlock.unlock();}
- try{nextl=cursor.curr().prevlock.tryLock();
- t1=cursor.curr();
- prevl=cursor.curr().prev().nextlock.tryLock();
- t2=cursor.curr().prev();
- }catch(NullPointerException e1){
- cursor.curr(e);
- }
- if(nextl&&prevl){
- if(t1.prev()==t2)
- unchanged=true;
- else
- unchanged=false;
- }
- }
-
- //System.out.println(cursor.curr());
- //System.out.println(cursor.curr().prevlock);
- if(cursor.curr()==null)
- cursor.curr(e);
- else{
- cursor.curr().addBefore(e);
- cursor.prev();
- //System.out.println(cursor.curr());
- }
-
- }
- finally{
-// System.out.println("access succesfully"+cursor.curr().prev()+cursor.curr().next());
-// System.out.println(cursor.curr().prev().nextlock);
-// System.out.println(cursor.curr().next().prevlock);
-//// if(nextl){
-// //cursor.curr().prev().nextlock.notifyAll();
-// cursor.curr().prev().nextlock.notifyAll();
-//// }
-//// if(prevl){
-// //cursor.curr().next().prevlock.await();
-// cursor.curr().next().prevlock.notifyAll();
-//// }
-//
- if(nextl){cursor.curr().next().prevlock.unlock();}
- if(prevl){cursor.curr().prev().nextlock.unlock();
-
- }
- }
-
- return true;
-
-
- }
-
-
- public boolean insertAfter(T val) {
- //System.out.println("insert after "+val+" "+Thread.currentThread().getId());
- boolean prevl=false;
- boolean nextl=false;
- fineElement<T> e = new fineElement<T>(val);
- try{
- while(!(prevl&&nextl)){
- if(prevl){cursor.curr().next().prevlock.unlock();}
- if(nextl){cursor.curr().nextlock.unlock();}
- try{nextl=cursor.curr().nextlock.tryLock();
- prevl=cursor.curr().next().prevlock.tryLock();
- }catch(NullPointerException e1){
- cursor.curr(e);
- }
- }
-
-
- cursor.curr().addAfter(e);
- cursor.next();
-
- }
- finally{
- if(prevl){cursor.curr().next().prevlock.unlock();}
- if(nextl){cursor.curr().prev().nextlock.unlock();}
-
- }
- return true;
-
- }
-
- public boolean delete() {
- //System.out.println("delete "+Thread.currentThread().getId());
- //System.out.println("delete");
- boolean prev1=false;
- boolean prev2=false;
- boolean next1=false;
- boolean next2=false;
- try{
- while(!(prev1&&prev2&&next1&&next2)){
- if(next1){cursor.curr().prev().nextlock.unlock();}
- if(prev1){cursor.curr().prevlock.unlock();}
- if(next2){cursor.curr().nextlock.unlock();}
- if(prev2){
- cursor.curr().next().prevlock.unlock();
- }
- try{next1=cursor.curr().prev().nextlock.tryLock();
- prev1=cursor.curr().prevlock.tryLock();
- next2=cursor.curr().nextlock.tryLock();
- prev2=cursor.curr().next().prevlock.tryLock();
- }catch(NullPointerException e){
- throw new Error("the list is empty");
- }
- }
- if(cursor.getnext()==cursor.getprev() && cursor.getnext()==cursor.curr()){
- //System.out.println("delete "+cursor.curr().value());//only one element in the list
- cursor.curr(null);
- }
- else{
- cursor.curr().delete();
- cursor.curr(cursor.curr().prev());
- }
-
- }
- finally{
- if(cursor.curr()!=null){
- if(next1){cursor.curr().nextlock.unlock();}
- if(prev2){cursor.curr().next().prevlock.unlock();}
- }
- }
-
- // TODO Auto-generated method stub
- return true;
- }
-
-}
View
29 src/edu/buffalo/cse605/finelist/src/testThread.java
@@ -1,29 +0,0 @@
-package edu.buffalo.cse605.finelist.src;
-
-public class testThread extends Thread{
-
- fineCursor<String> c;
- public testThread(fineFDList<String> a){
- c = a.freader( a.head() );
- }
- public void run(){
-
-// c.fwriter().insertBefore("good");
-//
-// c.fwriter().insertAfter("hi2");
-
- for(int i=0;i<50;i++){
- System.out.println("this is the "+i);
- c.fwriter().insertAfter("bad" + i);
- }
-
-
- //catch(InterruptedException e){}
-// for(int i=0;i<52;i++)
-// c.fwriter().delete();
- // c.fwriter().delete();
- //c.fwriter().delete();
- //c.fwriter().delete();
-
- }
-}
View
20 src/edu/buffalo/cse605/finelist/src/testThread2.java
@@ -1,20 +0,0 @@
-package edu.buffalo.cse605.finelist.src;
-
-public class testThread2 extends Thread{
- public fineCursor<String> c;
- public testThread2(fineFDList<String> f){
- c=f.freader(f.head());
- }
- public void run(){
-
- //try{this.sleep(500);}catch(InterruptedException e){}
- for(int i=0;i<50;i++){
- c.fwriter().delete();
- System.out.println("this is the "+i +"delete");
- }
- for(int j=0;j<50;j++){
- //System.out.println("good");
- c.fwriter().insertBefore("beautiful" + j);
- }
- }
-}
View
21 src/edu/buffalo/cse605/list/Writer.java
@@ -26,7 +26,6 @@ public boolean insertAfter(T val) {
Element<T> e = new Element<T>(val);
if ( cursor.curr() == null ) {
cursor.curr(e);
-
} else {
cursor.curr().addAfter(e);
cursor.next();
@@ -36,17 +35,15 @@ public boolean insertAfter(T val) {
@Override
public boolean delete() {
-// synchronized (cursor.list) {
- if (cursor.curr() == null) {
- throw new Error("the list is empty");
- } else if (cursor.getnext() == cursor.getprev() && cursor.getnext() == cursor.curr()) {
- cursor.curr(null);
- } else {
- cursor.curr().delete();
- cursor.prev();
- }
- return true;
-// }
+ if (cursor.curr() == null) {
+ throw new Error("the list is empty");
+ } else if (cursor.getnext() == cursor.getprev() && cursor.getnext() == cursor.curr()) {
+ cursor.curr(null);
+ } else {
+ cursor.curr().delete();
+ cursor.prev();
+ }
+ return true;
}
}
View
8 src/edu/buffalo/cse605/list/fine/CursorFine.java
@@ -28,13 +28,11 @@ public void next() {
this.curr = curr.next();
}
-
-
- public ElementFine getnext(){
+ public ElementFine<T> getnext(){
return this.curr.next();
}
- public ElementFine getprev(){
+ public ElementFine<T> getprev(){
return this.curr().prev();
}
@@ -43,7 +41,7 @@ public void prev() {
}
- public WriterFine<T> fwriter() {
+ public WriterFine<T> writer() {
return writer;
}
View
2 src/edu/buffalo/cse605/list/fine/FDListFine.java
@@ -13,7 +13,7 @@ public FDListFine(T val) {
return this.head;
}
- public CursorFine<T> freader(ElementFine<T> start) {
+ public CursorFine<T> reader(ElementFine<T> start) {
cursor = new CursorFine<T>(start);
return this.cursor;
}
View
217 src/edu/buffalo/cse605/list/fine/WriterFine.java
@@ -7,150 +7,113 @@ public WriterFine(CursorFine<T> cursor) {
this.cursor=cursor;
}
-
public boolean insertBefore(T val) {
- ElementFine<T> e = new ElementFine<T>(val);
- boolean prevl=false;
- boolean nextl=false;
- boolean unchanged=true;
- ElementFine<T> t1=cursor.curr();
- ElementFine<T> t2=cursor.curr();
- try {
- while((!(prevl && nextl)) && unchanged){
- if(prevl){
- cursor.curr().prev().nextlock.unlock();
- }
- if(nextl) {
- cursor.curr().prevlock.unlock();
- }
- try {
- nextl = cursor.curr().prevlock.tryLock();
- t1 = cursor.curr();
- prevl = cursor.curr().prev().nextlock.tryLock();
- t2 = cursor.curr().prev();
- } catch (NullPointerException e1){
- //cursor.curr(e);
- throw new Error("the cursor points to null");
- }
- if (nextl && prevl) {
- if(t1.prev()==t2) {
- unchanged = true;
- } else {
- unchanged=false;
- }
+ ElementFine<T> e = new ElementFine<T>(val);
+ ElementFine<T> prev = cursor.getprev();
+ ElementFine<T> curr = cursor.curr();
+ try {
+ while ( prev.nextlock.tryLock() &&
+ curr.prevlock.tryLock() ) {
+ // Make sure they are still pointing to the ones they were supposed to point
+ // This messes the performance
+ if ( prev.next() == curr &&
+ curr.prev() == prev ) {
+ if ( cursor.curr() == null ) {
+ cursor.curr(e);
+ } else {
+ curr.addBefore(e);
+ cursor.prev();
}
- }
- cursor.curr().addBefore(e);
- cursor.prev();
- } finally {
- if (nextl) {
- cursor.curr().next().prevlock.unlock();
- }
- if (prevl) {
- cursor.curr().prev().nextlock.unlock();
+ break;
+ } else {
+ throw new Exception("inconsitent");
}
}
- return true;
-
-
+ cursor.getnext().prevlock.unlock();
+ prev.nextlock.unlock();
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ } finally {
+ // This shouldn`t mess up
+// prev.nextlock.unlock();
+// cursor.getnext().prevlock.unlock();
+ }
+ return true;
}
public boolean insertAfter(T val) {
- //System.out.println("insert after "+val+" "+Thread.currentThread().getId());
- boolean prevl=false;
- boolean nextl=false;
- boolean unchanged=true;
- ElementFine<T> t1=null;
- ElementFine<T> t2=null;
ElementFine<T> e = new ElementFine<T>(val);
- try{
- while(!(prevl&&nextl)&&unchanged){
- if(prevl){cursor.curr().next().prevlock.unlock();}
- if(nextl){cursor.curr().nextlock.unlock();}
- try{nextl=cursor.curr().nextlock.tryLock();
- t1=cursor.curr();
- prevl=cursor.curr().next().prevlock.tryLock();
- t2=cursor.curr().next();
- }catch(NullPointerException e1){
- //cursor.curr(e);
- throw new Error("the cursor point to null");
- }
- if(nextl&&prevl){
- if(t1.next()==t2)
- unchanged=true;
- else
- unchanged=false;
- }
+ ElementFine<T> next = cursor.getnext();
+ ElementFine<T> curr = cursor.curr();
+ try {
+ while ( next.prevlock.tryLock() &&
+ curr.nextlock.tryLock() ) {
+ // Make sure they are still pointing to the ones they were supposed to point
+ // This messes the performance
+ if ( next.prev() == cursor.curr() &&
+ curr.next() == next ) {
+ if ( cursor.curr() == null ) {
+ cursor.curr(e);
+ } else {
+ curr.addAfter(e);
+ cursor.next();
+ }
+ break;
+ } else {
+ throw new Exception("inconsitent");
+ }
}
-
-
- cursor.curr().addAfter(e);
- cursor.next();
-
- }
- finally{
- if(prevl){cursor.curr().next().prevlock.unlock();}
- if(nextl){cursor.curr().prev().nextlock.unlock();}
-
+ cursor.getprev().nextlock.unlock();
+ next.prevlock.unlock();
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ } finally {
+ // This shouldn`t mess up
+// next.prevlock.unlock();
+// cursor.getprev().nextlock.unlock();
}
return true;
-
}
public boolean delete() {
- //System.out.println("delete "+Thread.currentThread().getId());
- //System.out.println("delete");
- boolean prev1=false;
- boolean prev2=false;
- boolean next1=false;
- boolean next2=false;
- ElementFine t1=null, t2=null, t3=null;
- boolean unchanged=true;
- try{
- while(!(prev1&&prev2&&next1&&next2)&&unchanged){
- if(next1){cursor.curr().prev().nextlock.unlock();}
- if(prev1){cursor.curr().prevlock.unlock();}
- if(next2){cursor.curr().nextlock.unlock();}
- if(prev2){
- cursor.curr().next().prevlock.unlock();
- }
- try{next1=cursor.curr().prev().nextlock.tryLock();
- t1=cursor.curr().prev();
- prev1=cursor.curr().prevlock.tryLock();
- t2=cursor.curr();
- next2=cursor.curr().nextlock.tryLock();
-
- prev2=cursor.curr().next().prevlock.tryLock();
- t3=cursor.curr().next();
- }catch(NullPointerException e){
- throw new Error("the list is empty");
- }
- if(next1&&next2&&prev1&&prev2){
- if(t2.prev()==t1&&t2.next()==t3)
- unchanged=true;
- else
- unchanged=false;
- }
- }
- if(cursor.getnext()==cursor.getprev() && cursor.getnext()==cursor.curr()){
- //System.out.println("delete "+cursor.curr().value());//only one element in the list
- cursor.curr(null);
- }
- else{
- cursor.curr().delete();
- cursor.curr(cursor.curr().prev());
- }
-
- }
- finally{
- if(cursor.curr()!=null){
- if(next1){cursor.curr().nextlock.unlock();}
- if(prev2){cursor.curr().next().prevlock.unlock();}
+ ElementFine<T> prev = cursor.getprev();
+ ElementFine<T> curr = cursor.curr();
+ ElementFine<T> next = cursor.getnext();
+
+ try {
+ while ( prev.nextlock.tryLock() &&
+ curr.prevlock.tryLock() &&
+ curr.nextlock.tryLock() &&
+ next.prevlock.tryLock() ) {
+ // Make sure they are still pointing to the ones they were supposed to point
+ // This messes the performance
+ if ( prev.next() == curr &&
+ curr.prev() == prev &&
+ curr.next() == next &&
+ next.prev() == curr ) {
+ if (cursor.curr() == null) {
+ throw new Error("the list is empty");
+ } else if (cursor.getnext() == cursor.getprev() && cursor.getnext() == cursor.curr()) {
+ cursor.curr(null);
+ } else {
+ // Delete
+ cursor.curr().delete();
+ // Move the cursor to previous
+ cursor.curr(prev);
+ }
+ break;
+ } else {
+ throw new Exception("inconsitent");
+ }
}
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ } finally {
+ // This shouldn`t mess up
+ prev.nextlock.unlock();
+ next.prevlock.unlock();
}
-
- // TODO Auto-generated method stub
return true;
}
View
36 src/edu/buffalo/cse605/main/Main.java
@@ -1,11 +1,7 @@
package edu.buffalo.cse605.main;
-import edu.buffalo.cse605.list.Cursor;
-import edu.buffalo.cse605.list.FDList;
-import edu.buffalo.cse605.list.coarse.CursorCoarse;
-import edu.buffalo.cse605.list.coarse.FDListCoarse;
+import edu.buffalo.cse605.list.fine.CursorFine;
import edu.buffalo.cse605.list.fine.FDListFine;
-import edu.buffalo.cse605.test.testThread;
import edu.buffalo.cse605.test.testThread2;
public class Main {
@@ -15,19 +11,18 @@ public static void main(String[] args) {
long ttime = 0;
// FDListCoarse<String> = new FDListCoarse<String> ("hi");
- int nt = Integer.parseInt(args[0]);
-// CursorCoarse<String> c;
+ int nt = 4;//Integer.parseInt(args[0]);
+// CursorFine<String> c;
// c = f.reader( f.head() );
//
-// for ( int i = 0; i < 80000; i++ ) {
+// for ( int i = 0; i < 10000; i++ ) {
// c.writer().insertBefore(i+"");
// }
// c.prev();
-//
-//
+
System.out.println("=========== No.of Threads => " + nt + "=========");
- for (int i = 0; i < 100; i++) {
+ for (int i = 0; i < 10; i++) {
long startTime = System.currentTimeMillis();
Thread[] threads = new Thread[nt];
for (int j = 0; j < nt ; j++) {
@@ -47,21 +42,18 @@ public static void main(String[] args) {
long totalTime = endTime - startTime;
ttime += totalTime;
}
- System.out.println("Total running time => " + ttime/100);
-//
+ System.out.println("Total running time => " + ttime/2);
+
-//
// System.out.println("count => " + f.count.get());
// System.out.println("current element pointed by cursor..." + c.curr().toString());
//
// if (f.head() == c.curr()) {
// System.out.println("true");
// } else {
// System.out.println("false");
-// }
+// }
//
-
-
// System.out.println("current element pointed by cursor..." + c.curr().toString());
// c.next();
// System.out.println("head in list..." + f.head().value());
@@ -122,7 +114,15 @@ public static void main(String[] args) {
// c.writer().delete();
// c.writer().delete();
// c.writer().delete();
-// c.writer().delete();
+// c.writer().delete();
+//
+// // deleted last element ?
+// if (c.curr() == null) {
+// System.out.println("no elements left");
+// } else {
+// System.out.println("elements left");
+// }
+
}
}
View
35 src/edu/buffalo/cse605/main/Tester.java
@@ -1,35 +0,0 @@
-package edu.buffalo.cse605.main;
-
-import edu.buffalo.cse605.list.Cursor;
-import edu.buffalo.cse605.list.FDList;
-import edu.buffalo.cse605.list.coarse.CursorCoarse;
-import edu.buffalo.cse605.list.coarse.FDListCoarse;
-
-public class Tester implements Runnable {
- FDListCoarse<String> list;
- CursorCoarse<String> c;
- int id;
-
- public Tester(FDListCoarse<String> list, int id) {
- this.list = list;
- this.id = id;
- }
-
- @Override
- public void run() {
- long startTime = System.currentTimeMillis();
-
-// synchronized(list) {
- c = this.list.reader( this.list.head() );
- c.prev();
- for ( int i = 0; i < 1250; i++ ) {
- c.writer().delete();
- }
-// }
-
- long endTime = System.currentTimeMillis();
- long totalTime = endTime - startTime;
- System.out.println("Thread-" + this.id + " running time => " + totalTime);
- }
-
-}
View
32 src/edu/buffalo/cse605/test/testThread.java
@@ -1,32 +0,0 @@
-package edu.buffalo.cse605.test;
-
-import edu.buffalo.cse605.list.fine.CursorFine;
-import edu.buffalo.cse605.list.fine.FDListFine;
-
-public class testThread extends Thread{
-
- CursorFine<String> c;
- public testThread(FDListFine<String> a){
- c = a.freader( a.head() );
- }
- public void run(){
-
-// c.fwriter().insertBefore("good");
-//
-// c.fwriter().insertAfter("hi2");
-
- for(int i=0;i<50;i++){
- System.out.println("this is the "+i);
- c.fwriter().insertAfter("bad" + i);
- }
-
-
- //catch(InterruptedException e){}
-// for(int i=0;i<52;i++)
-// c.fwriter().delete();
- // c.fwriter().delete();
- //c.fwriter().delete();
- //c.fwriter().delete();
-
- }
-}
View
7 src/edu/buffalo/cse605/test/testThread2.java
@@ -8,13 +8,14 @@
int i;
public testThread2(FDListFine<String> f, int i){
this.i = i;
- c = f.freader(f.head());
+ c = f.reader(f.head());
}
public void run(){
// long startTime = System.currentTimeMillis();
- for(int j=0; j < 10000/i; j++){
- c.fwriter().insertBefore("beautiful" + j);
+ for(int j=0; j < 100000/i; j++){
+ c.writer().insertBefore("beautiful" + j);
+ c.writer().insertAfter("beautiful" + j);
}
// long endTime = System.currentTimeMillis();
// long totalTime = endTime - startTime;

0 comments on commit 89df5df

Please sign in to comment.