how to run this program in eclipse,,as i have installed this eclipse in ubuntu,.do i have to add any package name???whn i stared debuging this program it gave 4 errors and i warning..by default what we give package name???/is it necessary that everytime v have to give package name?????
Write a multi-threaded Java program to print all numbers below 100,000 that are
both prime and fibonacci number (some examples are 2, 3, 5, 13, etc.). Design a
thread that generates prime numbers below 100,000 and writes them into a pipe.
Design another thread that generates fibonacci numbers and writes them to another
pipe. The main thread should read both the pipes to identify numbers common to
both.
hiiiiiiiiiii
i m inspired from this website.
but i want to say something about this that you should improve program because more program have more error .....
using this new user will more satisfy
Ramnarayan.......
java notessantoshanand lathkar February 3, 2012 at 11:35 AM
best site i have ever vigited
questionBonie Jay Manatad February 6, 2012 at 6:43 AM
i looking every tutorial about java in this site.i have a problem about .its may b new idea.sml thing.bcx i decide to say every examples after the given there avnswr.its easy to understand.
core javaPreeti Yadav April 9, 2011 at 9:31 PM
How i can make a little game in java?
javakrishbna April 11, 2011 at 12:56 PM
Threads in java
corejavasanjeeva June 18, 2011 at 6:22 PM
very nise
javaShaukat Ali Shahee June 27, 2011 at 11:55 AM
Very nice !!!
javaranjay June 29, 2011 at 9:16 AM
learning core java
doubtxyz July 29, 2011 at 12:05 PM
how to run this program in eclipse,,as i have installed this eclipse in ubuntu,.do i have to add any package name???whn i stared debuging this program it gave 4 errors and i warning..by default what we give package name???/is it necessary that everytime v have to give package name?????
could u tell me ans for this programvijayaragavan September 19, 2011 at 11:08 AM
Write a multi-threaded Java program to print all numbers below 100,000 that are both prime and fibonacci number (some examples are 2, 3, 5, 13, etc.). Design a thread that generates prime numbers below 100,000 and writes them into a pipe. Design another thread that generates fibonacci numbers and writes them to another pipe. The main thread should read both the pipes to identify numbers common to both.
running ExampleVinil Mehta October 2, 2011 at 2:48 PM
i couldnt understand why did this example runs as we didnt implement runnable now inherit thread class.?what is this thread th= new Thread()????
JAVAkunal November 11, 2011 at 9:11 AM
what is theard in java
errorhemant January 3, 2012 at 4:20 PM
above example public class Threads extends Thread
Javaneha January 9, 2012 at 12:54 PM
it is very helpful to us... thnx..:)
java Sneha C.Shirke January 13, 2012 at 3:01 PM
good site..thanku so much
java Sneha C.Shirke January 13, 2012 at 3:03 PM
good site..thanku so much
java program relatedRAMNARAYAN January 23, 2012 at 12:46 PM
hiiiiiiiiiii i m inspired from this website. but i want to say something about this that you should improve program because more program have more error ..... using this new user will more satisfy Ramnarayan.......
java notessantoshanand lathkar February 3, 2012 at 11:35 AM
best site i have ever vigited
questionBonie Jay Manatad February 6, 2012 at 6:43 AM
How does thread used in gaming programs?
threadssiddartha February 7, 2012 at 1:10 PM
Super information
ThreadsRam chandra Bhakar March 14, 2012 at 1:09 PM
this is a good example
Correction in the above codesanjay March 16, 2012 at 10:20 PM
hi , u are wrong with the sleep method. sleep(arg) is a static method of Thread class. u should not call it via thread class object
javaprashant singh March 31, 2012 at 12:04 AM
nice thought and have got some special knowledge
produer consumergaurav May 25, 2012 at 10:34 PM
package ps; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.Writer; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Scanner; import java.util.StringTokenizer; import java.util.TreeMap; import java.util.Map.Entry; class CubbyHole { private int contents; private boolean available = false; File testFile = new File("C:\\test.txt"); ArrayList<Notifications> nofListMain= new ArrayList<Notifications>(); public synchronized int get() throws FileNotFoundException { while (available == false) { try { wait(); } catch (InterruptedException e) { } } readFromFile(); available = false; notifyAll(); return contents; } private void readFromFile() throws FileNotFoundException { try { // File f = new File("laww_protected_list.txt"); BufferedReader br = new BufferedReader(new FileReader(testFile) ); String line = ""; int count = 0; line=br.readLine(); String arrNot [] = new String [4]; while (line != null){ System.out.println(line); if (line != null) { count++; int i=0; StringTokenizer st = new StringTokenizer(line, ","); while(st.hasMoreTokens()){ arrNot[i]=st.nextToken(); i++; } } if(arrNot[3].equalsIgnoreCase("false")){ assignProcessor(arrNot); } line=br.readLine(); } } catch (Exception e) { e.printStackTrace(); } } private void assignProcessor(String[] arrNot) { String prio= arrNot[1]; Integer pr=new Integer(prio); TreeMap<Integer,String []> tMap=new TreeMap<Integer,String []>(); tMap.put(pr,arrNot); try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } Entry<Integer, String[]> entry= tMap.pollLastEntry(); entry.getValue(); Processors processor= new Processors(); processor.process(arrNot, nofListMain); } public synchronized void put(Notifications nfObj, ArrayList<Notifications> notList) throws IOException { // while (available == true) { /*try { wait(); } catch (InterruptedException e) { } }*/ //contents = value; writeIntoFile(nfObj, notList); available = true; notifyAll(); } private void writeIntoFile(Notifications contents, ArrayList<Notifications> notList) throws IOException { if (testFile == null) { throw new IllegalArgumentException("File should not be null."); } /*if (!testFile.exists()) { throw new FileNotFoundException ("File does not exist: " + testFile); }*/ if (!testFile.isFile()) { throw new IllegalArgumentException("Should not be a directory: " + testFile); } if (!testFile.canWrite()) { throw new IllegalArgumentException("File cannot be written: " + testFile); } nofListMain= notList; //use buffering Writer output = new BufferedWriter(new FileWriter(testFile, true)); //FileWriter always assumes default encoding is OK! try { if(contents!=null){ output.write( contents.getName()+","+contents.getPriority()+","+contents.getWork()+","+contents.isProcessed+"\n"); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { output.close(); } } }
Discuses JavaZeeshan July 3, 2012 at 7:40 PM
Good programing example give me
Javavicky July 18, 2012 at 3:47 PM
threats in java
new improvementkrishatha August 5, 2012 at 3:40 PM
i looking every tutorial about java in this site.i have a problem about .its may b new idea.sml thing.bcx i decide to say every examples after the given there avnswr.its easy to understand.
error in thread examplekomal August 17, 2012 at 4:55 PM
when i run the thread show error class ir imterface r excepted
e.printStackTrace();zahid hussain October 22, 2012 at 2:25 PM
e.printStackTrace(); my means it has what kind of function
Creating a fan using threadsEuphamia November 28, 2012 at 2:23 PM
Someone tolled me to visit your page and he said i wont regret
javasuresh kumar August 23, 2012 at 3:07 PM
all coding send my mail address
Post your Comment