allo
hi again
1 Answer(s)      4 years and 7 months ago
Posted in : Java Beginners

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 Pages:
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
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
, again the label with ââ?¬Å?+Click to add another accountââ?¬Â? should be enable
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
, display the menu again. the user should respond to this prompt with another
again with xml - XML
again with xml  hi all i am a beginner in xml so pls give me the details regarding the methods used in it. wat will return the methods.../content.aspx?b=STY_XML_21days&seqNum=207 Thanks Rajanikant  Hi
again java - Java Beginners
again java  i will ask iam using servlets ,in one program my requirement is if there is a image(if u like) in anywhere and we browse that image... .i need it pls help me.  Hi Friend, Have you got any error
again java - Java Beginners
again java  Hi, i will ask iam using servlets ,in one program my requirement is if there is a image(if u like) in anywhere and we browse... please tell me step by step procedure. pls help me.   Hi Friend
JFREE error again
JFREE error again  hi......... As i had asked u the jfree error i want to tel u that i have taken the both the jar files jfree and jcommon. but then also its giving me error i am able to compile the code but now when i am
Read data again - Java Beginners
Read data again  sir, i still hav a problem,first your code will be change like this : in netbeans out message error 5. Can you help me again. My... System.err.println("Error: " + e.getMessage()); }  Hi friend
Read data again - Java Beginners
Read data again  Hey, i want to ask again about how to read data from txt, My DB: kd_div varchar(15), nm_div varchar(30), dep varchar(25... data from txt file and send to DB.i'm using one button to call.  Hi
doesnt run again - Java Beginners
the soltion   Hi I am sending u again the code, this code run in my
help again plz sorry - Java Beginners
help again plz sorry  Thanks for giving me thread code but i have a question this code is comletelly right and i want to make it runs much faster...; onescounter=0; // testing every character for (int n=0 ;n  Hi
After Logout Back Button Should not work again
After Logout Back Button Should not work again  Hi deepak,, I am doing Login Page,.. IN That If Logout Then When I Click Logout Button It Should... Kindly Help me... your regards, Prudvi raj.   Hi, you would might
Plz chk it and reply again - Java Beginners
Plz chk it and reply again  Hi Deepak, Thanks for fast reply,your application is good,u write this code for user click the view database... fast reply.  Hi Ragini, Please specify your requirements
Hi Check this.... - Java Beginners
Hi Check this....  Hi Sakthi here.. Run This Code..   Hi sakthi Your code is not visible here, can u send again please.. Thanks
print hello n hi
print hello n hi  how to write a java program that prints "hello" 5 times, "hi" 1 time n again "hello" 4 times..?? do reply
submitting corect user and passowrd, it again comes on login.jsp - Struts
submitting corect user and passowrd, it again comes on login.jsp  i... and password, it again come in login.jsp. Here some files: Struts.xml.... thanks.  Hi Friend, Please visit the following link: http
when refreshing the page the data is stored in data base again
when refreshing the page the data is stored in data base again  Hi, In my application, I am adding form data in database on click of submit button.But the problem is, when user refreshes the page, the data added one more time
hi - Java Beginners
hi  hi sir,i want a program for when i am place the mouse cursor in textfield box then automatically 1 number is generated,again i am place..., plz provide the solution sir  Hi Friend, Try the following code
Hi,
Hi,  Hi,what is the purpose of hash table
Hi,
Hi,   labels = new Hashtable<Integer,JLabel>
Hi..
Hi..   what are the keywords available in simple HelloWorld program
Hi..
Hi..  what are access specifier available in java
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
hi,
hi,  print("code sample");how to display all elements in 2d array usin any one loop
Hi
Hi  Hi this is really good example to beginners who is learning struts2.0 thanks
Hi
Hi  Hi How to implement I18N concept in struts 1.3? Please reply to me
hi....
hi....  plzz sent me d code for counting vowels in a string... gui programme
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  I want import txt fayl java.please say me...   Hi, Please clarify your problem! 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   '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   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
There and Back Again
There and Back Again       The weblog of Joshua Eichorn, AJAX, PHP and Open Source Read full Description
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..  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!  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  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
hi
hi  what is the code for printing stars as follows * * * * * * * * * *print("code sample");   Hi Friend, Try this: public class PatternExample { public static void main(String[] args) { int
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   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..
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   I need some help I've got my java code and am having difficulty to spot what errors there are is someone able to help import java.util.Scanner; public class Post { public static void main(String[] args) { Scanner sc
hi.......
hi.......  i've a project on railway reservation... i need to connect netbeans and mysql with the help of jdbc driver... then i need to design... for such a programme... plz help me...   Hi Friend, Try this: import java.awt.
hi!
hi!  public NewJFrame() { initComponents(); try { Class.forName("java.sql.Driver"); con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","admin"); } catch(Exception e
hi.......
hi.......  /import java.awt.; import java.sql.*; import javax.swing.*; import java.awt.event.* public class NewJFrame extends javax.swing.JFrame... wts wrong with this code??   Hi, Check it: import java.awt.*; import

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.