Home Discussion Discuss: Java - Threads in Java

  • 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?????

  • Don't use Threadspetcomp August 26, 2011 at 9:16 PM

    I have heard a lot of talk about java being a mulithreaded application. The reality is that this is not the case. If you create a java swing application and start a thread with sleep, then the whole application is locked up until that thread starts. I can only think that this is because java is a class driven application and since you invariably will call a thread from within another class instance this is part of one and the same application! Rather schedule stuff in windows task scheduler than scheduling it within the application as this will certainly lock up the application until the thread starts!

  • java threadMithun August 31, 2011 at 7:28 AM

    its use full for java beginners...

  • JAVATEJAS September 5, 2011 at 12:20 PM

    THANK U SO MUCH I GOT THREAD INFORMATION ....

  • threads in javaabhay September 13, 2011 at 2:51 PM

    your providing materials realted to thread is too good. i need more examples on multiple threads in java

  • 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

  • java threadshimanshu mishra November 27, 2013 at 9:21 PM

    when interrupted exception occur in java threads ?

  • javaambika pratap January 21, 2014 at 11:28 AM

    jdbc aur database connectivity kishe hota hai sir

  • threads in javaraja June 30, 2014 at 12:46 PM

    plsss send all by using thread programes code

  • javasuresh kumar August 23, 2012 at 3:07 PM

    all coding send my mail address

Post your Comment



Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Related Articles
Java Beginners

java
java  diff bt core java and java 

Java Interview Questions

java
java  what is java 

Java Beginners

java
java  explain technologies are used in java now days and structure java 

Java Interview Questions

java
java   why iterator in java if we for loop 

Java Beginners

Java
Java   Whether Java is pure object oriented Language 

Java Interview Questions

java
java  different between java & core java 

Java Beginners

JAVA
JAVA  how the name came for java language as "JAVA 

Java Beginners

java
java  what is java reflection 

Java Beginners

java
java  is java open source 

Java Interview Questions

java
what is the size of array in java ?  what is the size of array in java ? what is the mean of finalize in java 

Java Interview Questions

java
java   in java does not pointers concept but what is nullpointers in java?   nullpointer is a runtime Exception 

Java Beginners

java
java  write a java program using filenotfoundexception 

Java Beginners

java
java   difference between class and interface 

Java Interview Questions

java
java  why multiple inheritance is not possible in java 

Java Interview Questions

java
java  send me java interview questions 

Java Interview Questions

java
java  Write a java code to print "ABABBABCABABBA 

Java Beginners

java
java  why to set classpath in java 

Java Beginners

java
java  RARP implementation using java socket 

Java Interview Questions

java
java  is java purely object oriented language 

Java Beginners

java
java  how use java method 

JavaMail Questions

java
java  write a program in java to acess the email 

Java Beginners

java
java  why to set classpath in java 

Java Beginners

java
java  why to set classpath in java 

Java Beginners

java
java  give a simple example for inheritance in java 

Java Beginners

Java
Java  how to do java in command prompt 

JavaMail Questions

java
java  sample code for RARP using java 

Java Beginners

Java
Java  how to draw class diagrams in java 

Java Interview Questions

java
java  explain object oriented concept in java 

Java Beginners

Java
Java   Whether Java is Programming Language or it is SOftware 

Java Beginners

java
java  what are JAVA applications development tools 

DMCA.com