Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 03-30-2002, 06:28 PM   #1
Member (7 bit)
 
snow's Avatar
 
Join Date: Feb 2002
Location: Indianapolis, IN
Posts: 110
Send a message via AIM to snow
Java

Hi, I've got problems w/ this code and I'm not sure what's up. I thought this made logical sense, and my programming teacher (who doesn't speak english very well) told me it was logical, but all he's done is give me examples of multithreading. Which don't seem to be what I want for this case (w/ the thread.sleep function). This is my own personal project, so you don't have to worry about this actually being for the class. Thanx in advance for any help you can give.

snow

(I know the blocking is weird, but it looks more logical to me that way-- sorry.)

P.S. I had to make it a regular text file cause the forum doesn't exept files w/ Java extensions
Attached Files
File Type: txt matrix7.txt (871 Bytes, 54 views)
snow is offline   Reply With Quote
Old 03-31-2002, 10:44 AM   #2
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
You didn't mention the job of this code, so I can't know if this code is logical or not, please tell me what do you want from your code so I can help you more.

I can give some notes though:

Line 6:
your code: class static exec{
correct code: static class exec{
Reason: Modifiers (like public, static, final ...) should be before the class declaration, or the compiler won't accept the code.

Line 21:
Here, you use a run method with a boolean parameter called line1on, when the line1a object is executed, this mothed won't be invoked, instead, a run method (inherited from the Thread class) with no parameters and with an empty body will be executed, if you want your run method to be executed when the line1a object is started, remove the parameter and add matrix7. before each line1on in the run method body.
BTW, even if the current run method is executed, the parameter line1on won't have the same value as the static field in class matrix7.

Line 37:
You missed a { after the while statement.

Line 39:
Your code: exec.a();
Correct code: e.a();
I think you already know why, method a is a non-static method, so you need an instance of exec to invoke it.

Other notes:

  • You used a lot of inner classes to subclass Thread, this makes you code difficult to understand and difficult to maintain, cosider using anonymous inner classes or implementing the Runnable interface.
  • Your code, after doing mentioned corrections, creates threads and starts them in a while statement, the result is creating a huge number of threads until the condition becomes flase.


Again, please tell me what do you want from this code so I can help you more.
aym is offline   Reply With Quote
Old 03-31-2002, 02:17 PM   #3
Member (7 bit)
 
snow's Avatar
 
Join Date: Feb 2002
Location: Indianapolis, IN
Posts: 110
Send a message via AIM to snow
thanx

thanx, a lot of that looks really stupid of me in hindsight, but I'm new to this and I don't catch everything. I"m slowly working through this Java book, and I was doing this matrix project as a side thing as I learned the material to execute it. Basically, I'm trying to recreate the opening scene ("Wake up, Neo... Cls "The matrix has you...) and I'm slowly but surely getting through some stuff. I picked up the sleep function (which is way beyond where I am in this book) from a post on the Sun Java forum-- so I"m not surprised if the syntax is off a bit. The boolean while loop stuff was another option I was trying instead of multithreading (I'm one of those people that once they think of an alternate way of doing something, they have to try it-- plus I don't totally get the multithreading and my teacher doesn't speak english very well). I wanted to run the first thread, clear the screen, run the second thread, etc. And that would work if I could get windows to clear the screen during a Java execution(it works fine under Linux). I know I'm rambling, but I hope that gives you a better idea. THANX A LOT! I don't think I would have figured this out on my own for a very long time.

nate

P.S. I'll fix those errors right after easter dinner
snow is offline   Reply With Quote
Old 04-01-2002, 01:13 PM   #4
aym
Registered User
 
aym's Avatar
 
Join Date: Nov 2001
Posts: 1,965
OK, keep up the good work
aym is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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

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



All times are GMT -5. The time now is 07:53 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2