Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


allo
hi again
1 Answer(s)      6 years and a month ago
Posted in : Java Beginners



Advertisement
View Answers

October 20, 2008 at 10:21 AM


Hi friend,



Do changes in Code :

Thread.sleep(1);


import java.io. *;
import java.util.*;

class MyThread1 implements Runnable{
Thread t;
String s="0";
String s1=null;
MyThread1(String s2){
s1=s2;
t=new Thread(this);
t.start();
}

public void run(){
try
{
Thread.sleep(1);
System.out.println(s1);

float counter=0;
float onescounter=0;
double x = 0.0 ;
double AP ;
double time;
double mins;
String byt="";
double num = Math.pow(2,8);

System.out.println("Processing just started!");
time = System.currentTimeMillis();
System.out.println("Starting test" + time);

for(int i =1 ; i<num; i++)
{
byt = Integer.toBinaryString(i);
String s = "0";
while(byt.length()<8)
{
byt= s+ byt;
}
x = 0.0;
counter=0;
onescounter=0;
// testing every character
for (int n=0 ;n<byt.length(); n++)
{
if( byt.charAt(n) == '1')
{
counter++;
onescounter++;
x = x + (onescounter/counter);

}
else
counter++;

}

AP = x * 1/onescounter;
System.out.println (" \nNumber is = " + byt);
System.out.println (" \nAverage Precisoon = " + AP);
}
time = System.currentTimeMillis() - time;
System.out.println(" The test took " + time + " milliseconds\n\n");
mins=time/60000;
System.out.println(" The test took " + mins + " munits\n\n");

}
catch (Exception e)
{
}

}
}

public class AveragePrecision{
public static void main(String args[]) throws Exception {
MyThread1 m1=new MyThread1("Thread started1....");
MyThread1 m2=new MyThread1("Thread started2....");
MyThread1 m3=new MyThread1("Thread started3....");
MyThread1 m4=new MyThread1("Thread started4....");
MyThread1 m5=new MyThread1("Thread started5....");
}
}

For any more problem give details and more information on Thread visit to :

http://www.roseindia.net/java/thread/index.shtml

Thanks


Related Tutorials/Questions & Answers:
hi again - Java Beginners
hi again  i did the changes on the code but still the time is not decreasing i wanna reach increasing running time target sorry for asking too...; // testing every character for (int n=0 ;n  Hi friend, Do changes
Hi..Again Doubt .. - Java Beginners
Hi..Again Doubt ..  Thank u for ur Very Good Response...Really great.. i have completed that.. If i click the RadioButton,,ActionListenr should get... WORRY WE'ILL ROCK "); } } }   Hi Can u send your MainMenu.java
Advertisements
Hi .Again me.. - Java Beginners
Hi .Again me..  Hi Friend...... can u pls send me some code on JPanel.. JPanel shoul have 1pic 1RadioButton .. Like a Voter List... REsponse me..  Hi friend, import java.io.*; import java.awt.
Hi
Hi   I have got this code but am not totally understanding what the errors. Could someone Please help. Thanks in advance! import java.util.Random...!"); // this says to guess higher System.out.print("Wrong! Again Guess
Hi,
Hi,  Hi,what is the purpose of hash table
hi
, again the label with â??+Click to add another accountâ?? should be enable
hi
, display the menu again. the user should respond to this prompt with another
Hi..
Hi..   what are the keywords available in simple HelloWorld program
Hi..
Hi..  what are access specifier available in java
Hi,
Hi,   labels = new Hashtable<Integer,JLabel>
HI.
HI.  hi,plz send me the code for me using search button bind the data from data base in dropdownlist
Hi..
Hi..  null is a keyword.True/False?   hi friend, In Java true, false and null are not a Java keyword they are literals in Java. For reading in detail go through the following link The null keyword
There and Back Again
There and Back Again       The weblog of Joshua Eichorn, AJAX, PHP and Open Source Read full Description
hi....
hi....  plzz sent me d code for counting vowels in a string... gui programme
Hi
Hi  Hi How to implement I18N concept in struts 1.3? Please reply to me
Hi
Hi  Hi this is really good example to beginners who is learning struts2.0 thanks
hi,
hi,  print("code sample");how to display all elements in 2d array usin any one loop
Hi
Hi   how to read collection obj from jsp to servlet and from jsp - jsp?   Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/servlet-jsp-data-list.shtml Thanks
hi....
hi....  a programme which displays a combobox which contains num from 1 to 10 and calculates the factorial of dt num which user clicks
Hi
Hi  I want import txt fayl java.please say me...   Hi, Please clarify your problem! Thanks
hi
hi   I have connected mysql with jsp in linux and i have used JDBC connectivity but when i run the program, its not working the program is displaying
hi
hi   'print("code sample");`class example(){ public.static.void.main(); system.out.println("this is first pro");}   class example{ public static void main(String[]args){ System.out.println("this is first pro
Hi..
Hi..  diff between syntax and signature?   signature is a particular identity of a method in terms of its argument order ,type and their number e.g. void A(arguments) then here the order ,type and number of arguments
Hi
Hi  Hi All, I am new to roseindia. I want to learn struts. I do not know anything in struts. What exactly is struts and where do we use it. Please help me. Thanks in advance. Regards, Deepak
hi!
hi!  how can i write aprogram in java by using scanner when asking user to enter element user will be free to enter any type that he/she wants to to enter, like(int,double,float,String,....) thanx for answering....   Hi
Hi..
Hi..  what are the steps mandatory to develop a simple java program?   To develop a Java program following steps must be followed by a Java developer : First of all the JDK (Java Development Kit) must be available
hi
hi   on clicking on button on 1st jsp page i want to display following options like friends,family,doctor etc.on next jsp page and also i want link to those options through which i can save the data from 1st jsp in different
hi
hi   on clicking on button on 1st jsp page i want to display following options like friends,family,doctor etc.on next jsp page and also i want link to those options through which i can save the data from 1st jsp in different
hi
online multiple choice examination  hi i am developing online multiple choice examination for that i want to store questions,four options,correct answer in a xml file using jsp or java?can any one help me?   Please
hi
hi  what is the code for printing stars as follows * * * * * * * * * *print("code sample");   Hi Friend, Try... num=4; int p = num; int q = 0; for (int i = 0; i <= num; i++) { for (int j
hi
hi  int A[]=new int{2,5,4,1,3}; what is the error in declaration of this   Hi Friend, This is the wrong way of declaring an array. Array is always declared in the following ways: 1)int arr[]=new int[5]; 2)int arr
 

 

 

DMCA.com