LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-05-2009, 04:11 PM   #1
ambius
LQ Newbie
 
Registered: Nov 2008
Location: Canada
Distribution: Fedora Core
Posts: 5

Rep: Reputation: 1
Wink Possible to attach sibling threads to parent context-switch? (java)


Maybe I'll just clarify as to what I meant by this title:

Suppose I have a program named MyProg.java like this:

Code:
import java.lang.*;

class myThread extends Thread
{
    public void run()
    {
        SiblingThreadOne.start();
        SiblingThreadTwo.start();
        .
        .
        .
        SiblingThreadN.start();
    }
}

class MyProg{
    public static void main(String args[])
    {
        //Scheduler switching between threads
        //[ParentThread1, ParentThread2, myThread, OtherParentThreads...]
    }
}

//go on to define parent threads
//and sibling threads
What I want to do is when myThread does a context-switch, the sibling threads are suspended as well. When the scheduler does a context-switch back to myThread, the sibling threads resume. The idea is to allow another developer to write a thread with siblings threads, compile it, and then plug it back into the program without his sibling threads coming into conflict with the parent threads, sibling threads, and functions of other developers.

Any help would be appreciated. Just something I'm trying to figure out. I honestly don't know if it's even possible unless there is some kind of callback function (or something) for the thread on a context-switch.

Thanks!
 
Old 09-05-2009, 08:16 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
"Context switches" are something that should be completely transparent at the application level.

The Java API is actually fairly rich in ways that Java threads can coordinate (when they need to), or work autonomously (when they can).

Depending on your "requirements" (your application-level goal), Java will probably let you achieve them.
 
1 members found this post helpful.
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
when context switch too much jackandking Linux - Software 0 01-16-2008 08:09 PM
Using system calls to create/context switch threads in assembly code casmac Programming 1 07-13-2007 04:48 PM
measuring context switch time between two threads sekhar Programming 1 06-01-2007 07:16 AM
Java threads listed using kill -3 does not contain all threads found using ps -auxww coneheed Programming 2 11-14-2005 08:57 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration