Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-28-2008, 05:12 PM
Member
 
Join Date: Mar 2008
Posts: 3
markyoung1984 is on a distinguished road
My thread will not start
I have my thread class (which transmits a datagram):

Code:
public class heartbeat extends Thread { private int portNum; private InetAddress address; private int siteNum; public heartbeat(InetAddress pAddress, int pPortNum, int pSiteNum) { portNum = 3001; address = pAddress; siteNum = pSiteNum; } public void Run() { byte[] buf = new byte[256]; String stringToSend = "[H," + siteNum + "]"; buf = stringToSend.getBytes(); System.out.println("Port is " + portNum); try { DatagramSocket socket = new DatagramSocket(portNum); DatagramPacket packet = new DatagramPacket(buf, buf.length, address, portNum); while(true) { System.out.println(stringToSend); socket.send(packet); } } catch (Exception e) { System.exit(0); } } }
and then the following two lines in my main program.

Code:
heartbeat myHeartbeat = new heartbeat(serverAddr, serverPort, siteID); myHeartbeat.start();
It all looks right to me but the thread will not run and I can't see whats wrong with it!! Please help.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-05-2008, 03:59 AM
CJG CJG is offline
Member
 
Join Date: Mar 2008
Posts: 1
CJG is on a distinguished road
Capitalization.

public void run() overrides the run method

public void Run() makes a new method that doesn't override it.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
data from the main/GUI thread to another runnin thread... cornercuttin Threads and Synchronization 2 04-23-2008 11:30 PM
If JNI thread call the java object in another thread, it will crash. skaterxu Advanced Java 0 01-28-2008 08:02 AM
Creating a Thread (extending Java Thread Class) JavaForums Java Blogs 0 12-19-2007 10:31 AM
OutOfMemoryError: Unable to Start New Native Thread edwin11 Advanced Java 0 11-16-2007 02:47 PM
How to start cachi Java Applets 1 08-06-2007 09:43 AM


All times are GMT +3. The time now is 04:23 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org