Advertise Here

Author Topic: [JavaTutorial]Creating a fundamental thread.  (Read 5116 times)

0 Members and 1 Guest are viewing this topic.

Offline Marsada

  • SMF For Free Newbie
  • *
  • Posts: 4
  • Java Assistant
    • View Profile

  • Total Badges: 9
    Badges: (View All)
    Topic Starter Combination Level 2 Level 1 First Post
[JavaTutorial]Creating a fundamental thread.
« on: February 09, 2009, 02:51:55 am »
Creating a fundamental thread

Requirements: General knowledge

Make a new class file and call it
Code: [Select]
public class MyThread {

public static void main(String[] agrs) throws InterruptedException {
String threadInfo[] = {
"Starting Thread 1",
"Starting Thread 2",
"Finished Thread"


for (int i = 0; i < threadInfo.length; i++) {

*Basically the you should all know the main method, this runs the project.
*throws InterruptedException enables the thread.
*StringthreadInfo is like a message tool.
* (for (int i = 0; i < threadInfo.length; i++) {) don't worry much about this code, this enables the String message with the thread.
*Thread.sleep(1000); The 1000 is the milliseconds, so this means right now it is set to (1)second.
*System.out.println(threadInfo); The System.out.println refers to as the command line print.It prints the message on to the command line in 1 second.

Thats about it for this tutorial.Thank you for visiting it.

*Copyright Marsada(c)

Offline Colette Brunel

  • SMF For Free Sr. Member
  • *
  • Posts: 424
    • View Profile

  • Total Badges: 17
    Badges: (View All)
    Poll Voter Level 4 Fourth year Anniversary Windows User Topic Starter
Re: [JavaTutorial]Creating a fundamental thread.
« Reply #1 on: February 09, 2009, 04:51:01 pm »
Generally for() loops repeat a statement over and over again until the second condition is met, and then parses out all the information that was met.

In some cases, for() loops are tools to check every set of data until it's correct. This reduces the amount of code you need to actually make (as defining each section of the array with foreach() or defining the array's key directly isn't optimal).


Related Topics

  Subject / Started by Replies Last post
15 Replies
Last post March 28, 2007, 10:14:19 am
by kronk
0 Replies
Last post April 01, 2007, 09:03:59 am
by Nintenfreak_101
6 Replies
Last post January 13, 2008, 02:24:21 pm
by cooldude101
0 Replies
Last post February 09, 2009, 07:57:56 pm
by Marsada
0 Replies
Last post February 09, 2009, 08:35:49 pm
by Marsada