Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Java Help

Java Help Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-02-2007, 06:34 PM
Lawtonfogle's Avatar   
Lawtonfogle Lawtonfogle is offline
Newbie
 
Join Date: Apr 2007
Posts: 8
Rep Power: 0
Lawtonfogle is on a distinguished road
Default I need the thread to multitask.

The point of threads are to allow a program to mulittask (at least in some cases), but I am needing a thread to multitask.

This is a part of my client and server chat server I have been making for scratch, just to know how to operate a server.

One server side thread gets stuck on this line of code.

command = in.readLine();

waiting for the BufferedReader, aka in, to get a comand from the client.

Of course, once it gets the command, I have a normal thread sleep.

What I am wondering is while I am waiting for something to be present to be read, is there a way to turn the waiting on and off?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 05-31-2007, 11:14 AM
oubless oubless is offline
Newbie
 
Join Date: May 2007
Posts: 22
Rep Power: 6
oubless is on a distinguished road
Post

Quote:
Originally Posted by Lawtonfogle View Post
What I am wondering is while I am waiting for something to be present to be read, is there a way to turn the waiting on and off?
Please specify ...
Do you mean the waiting after the line is read or do you mean the waiting for that line itself?
In case the sleep/wait after that - just put a boolean variable and if:
Code:
...
   if( shouldSleepAfterRead)
       Thread.sleep(...);
...
set shouldSleepAfterRead from some other thread ( the current is blocked in the reading ).

In case you need to stop the readLine() command - read about interrupt().
You can interrupt a thread:
Thread (Java 2 Platform SE 5.0)
Thread (Java 2 Platform SE 5.0)
Thread (Java 2 Platform SE 5.0)

Hope this helps ...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
thread problem dirkfirst C# Programming 9 01-15-2007 10:19 AM
Which Thread do Timers run on? NeedHelp C# Programming 3 07-17-2006 04:22 PM
The UI Thread NeedHelp C# Programming 1 07-12-2006 10:47 PM
The ultimate xHTML / DHTML / HTML 301 redirection thread! Dan HTML Programming 5 07-04-2006 06:57 PM
The Ultimate Codefusion 301 direct/forwarding thread! Dan ASP, ASP.NET and Coldfusion 0 06-28-2006 09:28 PM


All times are GMT -5. The time now is 11:37 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads