Penggunaan 10 threads untuk output masing2 100,000 baris tidak lebih cepat dari single thread.
Err.. tujuan saya ini untuk mencari tahu apa yang membuat puts begitu cepat (4.4 kali dari System.out.println nya Java) Java gak boleh maen licik pake multi-threading donk :P hehe. Felix Halim 2008/6/2 Feris Thia <[EMAIL PROTECTED]>: > Wow.. belum tidur? > > Sama dong... hehehe > > O iya, pakai thread boleh ga ? kalau boleh, ini ada code saya berikut.. coba > gabungkan dengan code kamu.. mungkin bisa lebih kencang lagi ? ;) > > ============================= > package test.io; > > public class JajalIO { > public static void main(String[] args) { > for(int i=1;i<=10;i++) > { > ConsumeThread.getThread(100000).start(); > } > } > } > ============================= > package test.io; > > import java.io.PrintWriter; > > public class ConsumeThread extends Thread { > int mycounter; > int batas; > PrintWriter out; > > private ConsumeThread(int c) > { > out = new PrintWriter(System.out); > batas = c; > mycounter=0; > } > > public void run() > { > while(mycounter<batas) { > mycounter++; > out.write("Felix\n",0,6); > if(mycounter==500) out.flush(); > } > if(mycounter>(batas-500)) out.flush(); > } > > public static ConsumeThread getThread(int c) > { > return new ConsumeThread(c); > } > } > > > 2008/6/1 Felix Halim <[EMAIL PROTECTED]>: >> > > > > -- > Thanks & Best Regards, > > Feris > PT. Putera Handal Indotama > A Business Intelligence Company > Jl. K.H. Moh Mansyur No. 11 B 8 - 12 > Jakarta - Indonesia > Phone : +6221-30119353 > Fax : +6221-5513483 > Mobile : +628176-474-525 > http://business-intelligence.phi-integration.com > http://blog.komputasiawan.com