Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (482)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (547)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Threading issue  (Read 1337 times)
0 Members and 1 Guest are viewing this topic.
Offline morchi

Junior Newbie




Java games rock!


« Posted 2004-10-06 11:30:28 »

Hi everyone~

Want to ask, if i got a method to send something to the network using SocketChannel's write(), will it be safe if multiple threads are calling the method and pushing stuff?
What's the best way to do something like this? Keeping a vector and insert the stuff to send to it??
Offline morchi

Junior Newbie




Java games rock!


« Reply #1 - Posted 2004-10-07 02:31:25 »

Just wanna ask if it is wise to synchronize my sendMessage() method which calls the SocketChannel.write() or if it'll be better to keep a queue?
Offline morchi

Junior Newbie




Java games rock!


« Reply #2 - Posted 2004-10-08 06:15:28 »

Am I asking the wrong question here?... Huh
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #3 - Posted 2004-10-08 09:19:45 »

Quote
Am I asking the wrong question here?... Huh


Partly, yes. Your question is too vague and lacks important details - which is fine, except that it means it's more work for people to answer, hence probably fewer people are willing to have a go. For instance, you make no mention of the SC's mode (blocking or not). You also don't say precisely which method you're using.

However, more to the point, it looks like you didn't bother to read the API documentation. Maybe I'm misunderstanding your question, but it looks like you should just read the method comment for write( ByteBuffer ) [hint: look at the 5th paragraph]. IF that doesn't answer your question, then perhaps it will give you an idea of what you are asking that is differnt, and you can come back and ask a more detailed question that people can help with.

malloc will be first against the wall when the revolution comes...
Offline morchi

Junior Newbie




Java games rock!


« Reply #4 - Posted 2004-10-08 12:45:42 »

Turned out that my NIO concept's a bit wrong before(still a beginner now though...). Please forgive me for asking the stupid question :-/ (I admit I didn't read throughly the docs before=.=)
I've that sorted out now, thx blahblahblahh
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #5 - Posted 2004-10-08 13:43:23 »

IF you're new to nio, you might want to try the *incomplete* NIO tutorials on JGF (see link below, and go to the articles section) - there's enough there to get going quite far.

malloc will be first against the wall when the revolution comes...
Offline Tzan

Junior Member





« Reply #6 - Posted 2004-10-08 14:09:51 »

I read that tutorial a few weeks ago. I really liked it.
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #7 - Posted 2004-10-08 14:29:13 »

Quote
I read that tutorial a few weeks ago. I really liked it.


Great. You might want to also vote here: http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=Networking;action=display;num=1081097137;start=0
since I haven't signed the book contract yet, and the more responses that gets the happier it makes the publishers Wink.

malloc will be first against the wall when the revolution comes...
Offline Tzan

Junior Member





« Reply #8 - Posted 2004-10-08 14:51:00 »

Done Smiley
good luck
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (26 views)
2014-08-19 09:29:53

Tekkerue (24 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (13 views)
2014-08-16 06:20:21

Tekkerue (20 views)
2014-08-16 06:12:11

Rayexar (59 views)
2014-08-11 02:49:23

BurntPizza (38 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!