Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

example of using thread.

Thread view: 
Eitan M - 14 Jul 2006 10:20 GMT
Hello,
I need some samples of using threads.

Need also specific solution for :
there are  n threads in an array of thread,
each thread represent a value 1 to 100
(cyclic array, so thread-100 is the neighbour of thread-1).

First, I want to create the threads, each with a random value.
Second, as pseudo code (for thread_x) :

1) if  value of thread_x  < value the two neighbours value (together), then
increase the value of thread_x

2) if  value of thread_x  > value the two neighbours value (together), then
decrease the value of thread_x

3) if  value of prev_thread  <= value of thread_x <= value of next_thread
or
if  value of next_thread  <= value of thread_x <= value of prev_thread ,
then  stay with no change.

every thead continue checking its value, till it won't change.

Need to present the text : each line will present a step.

Two possible solution :
simultaniusly do : initialize values, check the values, update the values,
or simultaniusly every thread check and update.

Thanks :)
Andy Dingley - 14 Jul 2006 10:39 GMT
> I need some samples of using threads.

Weren't you given some in class, before the teacher set the homework?
pcbutts1 - 14 Jul 2006 15:31 GMT
Probably not. My teachers use of English is worse then my knowledge of java.

Signature

The best live web video on the internet http://www.seedsv.com/webdemo.htm
NEW Embedded system  W/Linux. We now sell DVR cards.
See it all at http://www.seedsv.com/products.htm
Sharpvision simply the best http://www.seedsv.com

>> I need some samples of using threads.
>
> Weren't you given some in class, before the teacher set the homework?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.