2 * To change this template, choose Tools | Templates
3 * and open the template in the editor.
6 package TransactionalIO.benchmarks;
8 import TransactionalIO.core.TransactionalFile;
9 import java.io.IOException;
10 import java.io.RandomAccessFile;
11 import java.util.logging.Level;
12 import java.util.logging.Logger;
18 public class lockthread1 extends Thread{
22 public lockthread1(RandomAccessFile file, char sample) {
35 byte[] b = new byte[20];
36 for (int j = 0; j < 19; j++) {
43 // f1 = (TransactionalFile)benchmark.m.get("0");
44 // f1 = (TransactionalFile)benchmark.m.get("0");
45 byte[] data = new byte[1];
46 char[] holder = new char[40];
47 benchmark.filelock.lock();
49 long toseek = Integer.valueOf(Thread.currentThread().getName().substring(7)) * 20448;
54 //////////////// skipt the first word since its been read already
55 while (data[0] != '\n') {
59 while (f1.getFilePointer() < toseek + 20448) {
63 while (data[0] != '\n') {
64 result = f1.read(data);
65 holder[i] = (char) data[0];
69 byte[] towrite = new byte[String.valueOf(holder, 0, i).length()];
70 towrite = String.valueOf(holder, 0, i).getBytes();
72 ((TransactionalFile) (benchmark.m.get(String.valueOf(holder,0,i).toLowerCase().substring(0, 1)))).file.write(towrite);
73 } catch (IOException ex) {
74 Logger.getLogger(thread1.class.getName()).log(Level.SEVERE, null, ex);
78 benchmark.filelock.unlock();
79 } catch (IOException ex) {
80 Logger.getLogger(lockthread1.class.getName()).log(Level.SEVERE, null, ex);